Ñò $&¯Mc@sFdZddkZddklZddkZddkZddkZddkZddkZddk Z ddk Z ddk Z ddk i iZddkiZddkiZdZdZdZd„Zd„Zd „Zd „Zd „ZdZdZdZd„Zd„Z d„Z!d„Z"d„Z#d„Z$d„Z%dS(sfeed - routines for generating RFC 4287 Atom feeds for packaging server At present, the pkg.server.feed module provides a set of routines that, from a catalog, allow the construction of a feed representing the activity within a given time period.iÿÿÿÿN(t serve_filesapplication/atom+xmlsfeed.xmls%Y-%m-%dT%H:%M:%SZcCs |itƒS(saReturns a string representing a datetime object formatted according to RFC 3339. (tstrftimet RFC3339_FMT(tts((s5/usr/lib/python2.6/vendor-packages/pkg/server/feed.pytdt_to_rfc3339_str4scCs titi|tƒdd!ŒS(svReturns a datetime object representing 'ts_str', which should be in the format specified by RFC 3339. ii(tdatetimettimetstrptimeR(tts_str((s5/usr/lib/python2.6/vendor-packages/pkg/server/feed.pytrfc3339_str_to_dt:scCs2d|i|iƒidƒti|iƒƒfS(ssGenerates a 'tag' uri compliant with RFC 4151. Visit http://www.taguri.org/ for more information. s tag:%s,%s:%ss%Y-%m-%d(t publishert get_timestampRturllibtunquotet get_url_path(tf((s5/usr/lib/python2.6/vendor-packages/pkg/server/feed.pytfmri_to_taguri@s cCst|dƒdS(soThis function performs general initialization work that is needed for feeds to work correctly. N(t __clear_cachetNone(tdepot((s5/usr/lib/python2.6/vendor-packages/pkg/server/feed.pytinitHscCs|idƒ}tiƒ}|i|iiddƒƒ|i|ƒ|i|ƒ|idƒ}|idti ƒƒ|iddƒ|i|ƒ|idƒ}tiƒ}t i ti ƒƒd d !\} } | i d d ƒd } d | |i dƒ| f} |i| ƒ|i|ƒ|i|ƒ|idƒ} tiƒ} | it |ƒƒ| i| ƒ|i| ƒ|idƒ}tiƒ}|i|iiddƒƒ|i|ƒ|i|ƒ|idƒ}tiƒ}|i|iiddƒƒ|i|ƒ|i|ƒdS(sêThis function attaches the necessary RSS/Atom feed elements needed to provide title, author and contact information to the provided xmini document object using the provided feed object and update time. ttitletpkg_buit feed_nametlinkthreftreltselftidiit:is tag:%s,%s:%ss%Y-%m-%dtupdatedticont feed_icontlogot feed_logoN(t createElementtxminitTexttreplaceWholeTexttcfgt get_propertyt appendChildt setAttributetcherrypyturlturlparsetsplitRR(Rtdoctfeedt update_tsttttitltitittnetloctpathttagtututtlt((s5/usr/lib/python2.6/vendor-packages/pkg/server/feed.pyt set_titlePs@     "           tAddeds%s was added to the repository.tRemoveds#%s was removed from the repository.tUpdatedsF%s, a new version of an existing package, was added to the repository.cCs5|idƒ}|\}}}} tiƒ} | it|ƒƒ|idƒ} | i| ƒ|i| ƒ|tiijo-||jot \} } qØt \} } n0|tii jot \} } n d} d} |idƒ}tiƒ}|idi | |i ƒgƒƒ|i|ƒ|i|ƒ|idƒ}tiƒ}|it|ƒƒ|i|ƒ|i|ƒti|dtit|ƒƒƒ}|id ƒ}|id d ƒ|id |ƒ|i|ƒ| |}tiƒ}|i|ƒ|id ƒ}|i|ƒ|i|ƒ|i|ƒdS(smEach transaction is an entry. We have non-trivial content, so we can omit summary elements. tentryRsUnknown Operations!%s was changed in the repository.Rt Rs info/0/%sRRt alternateRtcontentN(R#R$R%R&RR)tcatalogt CatalogUpdatetADDt update_optadd_optREMOVEtjoint get_pkg_stemRtmisct get_rel_pathR tquotetstrR*(trequestR/R0RAtfirsttetpfmritop_typetop_timetmetadataR5teidtop_titlet op_contenttetitleR3teuR;te_uriR4t content_texttcotec((s5/usr/lib/python2.6/vendor-packages/pkg/server/feed.pytadd_transactionˆsL     "            c Cs¸|i|ƒ}|i|jogStƒ}xr|iiƒD]a\}}|iddƒd}|djoq=n|d}||joq=n|i|ƒq=W|pgSt|ƒS(s£Returns a list of the CatalogUpdate files that contain the changes that have been made to the catalog since the specified UTC datetime object 'ts'.t.itCs last-modified(t get_catalogt last_modifiedtsettupdatest iteritemsR.taddtsorted( trepoRtpubtcRgtnametmdatatlocaletulog_lm((s5/usr/lib/python2.6/vendor-packages/pkg/server/feed.pytget_updates_neededÏs      c sy|iiddƒ}t|dƒ\}}|dd}|tid|d|ƒ}tiƒ} | iddƒ} | id dƒ|i i |ƒ‰t || | ˆi ƒ| i | ƒh‰‡‡fd †} x–tt|i ||ƒƒD]y} ti| d ˆiƒ} xX| iƒD]J}|d }|d }||joqnt|| | || |ƒƒqWqëW| i|ƒdS(sƒGenerate new Atom document for current updates. The cached feed file is written to depot.tmp_root/CACHE_FILENAME. Rt feed_windowii<tdaystsecondsshttp://www.w3.org/2005/AtomR0txmlnscs|iƒ}|ˆjo ˆ|SxHˆi|iƒD]4\}}x$|D]\}}|ˆ|iƒs%s was added to the repository.(R?s#%s was removed from the repository.(R@sF%s, a new version of an existing package, was added to the repository.(&t__doc__R+tcherrypy.lib.staticRR¤RR™RŽR’RR R-txml.dom.minidomtdomtminidomR$t pkg.catalogREtpkg.miscRMR´RRRR RRR=RIt remove_opRHRaRrRR‘RR­R¶(((s5/usr/lib/python2.6/vendor-packages/pkg/server/feed.pyts>              3 G # =  3