ó Í!nLc@sÖddlZddlZddlZddlZddljZddljZddlZddl Z ddl Z de fd„ƒYZ de fd„ƒYZ defd„ƒYZedƒZd „Zd „ZdS( iÿÿÿÿNtCatalogExceptioncBseZdd„Zd„ZRS(cCs ||_dS(N(t_args(tselftargs((s8/usr/lib/python2.7/vendor-packages/pkg/server/catalog.pyt__init__%scCs t|ƒS(N(tstr(R((s8/usr/lib/python2.7/vendor-packages/pkg/server/catalog.pyt __unicode__(sN(t__name__t __module__tNoneRR(((s8/usr/lib/python2.7/vendor-packages/pkg/server/catalog.pyR#s tCatalogPermissionsExceptioncBs eZdZd„Zd„ZRS(sWUsed to indicate the server catalog files do not have the expected permissions.cCs#|sg}ntj||ƒdS(sƒfiles should contain a list object with each entry consisting of a tuple of filename, expected_mode, received_mode.N(RR(Rtfiles((s8/usr/lib/python2.7/vendor-packages/pkg/server/catalog.pyR3s cCs\tdƒ}xI|jD]>}|\}}}|tdƒi|d6|d6|d67}qW|S(Ns8The following catalog files have incorrect permissions: s< %(fname)s: expected mode: %(emode)s, found mode: %(fmode)s tfnametemodetfmode(t_R(RtmsgtfR R R((s8/usr/lib/python2.7/vendor-packages/pkg/server/catalog.pyt__str__:s   (RRt__doc__RR(((s8/usr/lib/python2.7/vendor-packages/pkg/server/catalog.pyR /s t ServerCatalogcBsUeZdZejejBejBejBZde d„Z e dd„ƒZ d„Ze d„Zd„Ze ed„ƒZd„Zd„Zd „Zed „ƒZd „Zd „Zd d„Zd„Zd„Zed„ƒZedd„ƒZd d„Z dd„Z!dd„Z"d„Z#e d„ƒZ$e d„ƒZ%edd„ƒZ&RS(s,A Catalog is the representation of the package FMRIs available to the repository. This class is only used for compatibility with v0 repositories. The serialized structure of the repository is an unordered list of available package versions, followed by an unordered list of incorporation relationships between packages. This latter section allows the graph to be topologically sorted by the client. S Last-Modified: [timespec] XXX A publisher mirror-uri ... XXX ... V fmri V fmri ... C fmri C fmri ... I fmri fmri I fmri fmri ... In order to improve the time to search the catalog, a cached list of package names is kept in the catalog instance.cCsá||_tjjtjj|jdƒƒ|_i|_||_||_d|_ d|jd, , ... ], "version1": ( , { "pub1": known, "pub2": known, ... }, ), "version2": ( , { "pub1": known, "pub2": known, ... }, ), ... }, pkg_name2: { ... }, ... (where names in quotes are strings, names in angle brackets are objects, and the rest of the syntax is Pythonic). The fmri is expected not to have an embedded publisher. If it does, it will be ignored.R>tversionsiN( t has_publishertfmritPkgFmriRARBRR?tpkg_nametbisecttinsort(tdRGRtknowntpversion((s8/usr/lib/python2.7/vendor-packages/pkg/server/catalog.pyt cache_fmris'  ! cCsGg}x:|jjƒD])\}}d||f}|j|ƒqW|S(svTakes the list of in-memory attributes and returns a list of strings, each string naming an attribute.s S %s: %s (RtitemsR5(Rtrettktvts((s8/usr/lib/python2.7/vendor-packages/pkg/server/catalog.pytattrs_as_linesVs ccsiyt|jdƒ}Wn,tk rD}|jtjkr>dS‚nXx|D] }|VqLW|jƒdS(slReturns a generator function that produces the contents of the catalog as a list of strings.trN(RTRR#R$R/RV(RtcfileR,((s8/usr/lib/python2.7/vendor-packages/pkg/server/catalog.pytas_linesbs  cCs·d|jkr?djtƒ|jd<|js;|jƒndSt|jdƒ}|tkrbdStj|ƒ}|r³|j|ƒdj|ƒ|jd<|js³|jƒq³ndS(s>If this version of the catalog knows about new prefixes, check the on disk catalog to see if we can perform any transformations based upon previously unknown catalog formats. This routine will add a catalog attribute if it doesn't exist, otherwise it checks this attribute against a hard-coded version-specific tuple to see if new methods were added. If new methods were added, it will call an additional routine that updates the on-disk catalog, if necessary.tprefixtN(RRtknown_prefixesRt save_attrstsett differencetupdate(Rtpfx_settnew((s8/usr/lib/python2.7/vendor-packages/pkg/server/catalog.pyR(ts     cCs |js tStjj|jƒS(sNA boolean value indicating whether the Catalog exists on-disk.(RtFalseRRR!(R((s8/usr/lib/python2.7/vendor-packages/pkg/server/catalog.pyR!›s ccsy1ttjjtjj|jdƒƒdƒ}Wn,tk r_}|jtjkrYdS‚nXx”|D]Œ}|j dƒ r“|j dƒ r“qgny|j ||j ƒVWqgt t fk rÇ‚qgtk rò}td|j |fƒ‚qgXqgW|jƒdS(siA generator function that produces FMRIs as it iterates over the contents of the catalog.RRrNsV pkgsC pkgs,corrupt catalog entry for publisher '%s': %s(RTRRRRRRUR$R/t startswitht_ServerCatalog__parse_entryRtKeyboardInterruptt SystemExitRYt RuntimeErrorRV(RR^R,R_((s8/usr/lib/python2.7/vendor-packages/pkg/server/catalog.pytfmris¤s& % cCs|jjddƒS(s7Return the time at which the catalog was last modified.s Last-ModifiedN(RtgetR (R((s8/usr/lib/python2.7/vendor-packages/pkg/server/catalog.pyt last_modifiedÀsRcCsàtjjtjj|j|ƒƒ}tjj|ƒs:dSt|dƒ}tjdƒ}xK|D]C}|j |ƒ}|dkr_|j dƒ|j |j dƒ|rct|tjƒrc|jƒ|jd<  '     S & #   tCSVRcCstjjƒ}|jƒ}|S(s=Return an integer timestamp that can be used for comparisons.(RDRER®(ttobjttstr((s8/usr/lib/python2.7/vendor-packages/pkg/server/catalog.pyR¯âs cCsÂt|dd!ƒ}t|dd!ƒ}t|dd!ƒ}t|dd!ƒ}t|d d !ƒ}t|d d !ƒ}yt|d d!ƒ}Wntk r¢d}nXtj|||||||ƒS(sSTake timestamp ts in string isoformat, and convert it to a datetime object.iiiiii i i iiiiii(R‹t ValueErrorRD(RJtyeartmonthtdaythourtminutestsectusec((s8/usr/lib/python2.7/vendor-packages/pkg/server/catalog.pytts_to_datetimeés  (RfRDR$Rtpkg.fmriRct pkg.portableR-R‡R°RPRYRR tobjectRt frozensetRwR¯RÑ(((s8/usr/lib/python2.7/vendor-packages/pkg/server/catalog.pyts        ÿÿ›