#Tc@sdZddkZddkZddkZddkZddkZddkZddkZddkZddk Z ddk Z ddk Z ddk Z ddkZddkZddkiiZddkiiZddkiZddkiZddkiZddkZddklZddklZl Z de!fdYZ"de!fdYZ#d e#fd YZ$d e#fd YZ%d e#fdYZ&de!fdYZ'dZ(dZ)dZ*dZ+dZ,dZ-dZ.dZ/dS(srInterfaces and implementation for the Catalog object, as well as functions that operate on lists of package FMRIs.iN(t itemgetter(t EmptyDicttEmptyIt _JSONWriterc BskeZdZededZdZeeeeei ddddd Z dZ dZ dZ RS( sTPrivate helper class used to serialize catalog data and generate signatures.c Cs||_d|_||_d|_|o'|pti|_nd|_n||_ ||_ |pdSt i i |i }y#t i|}|ti|_WnRtj o2}|itijoti|iqntj o }nXyt|d|i}Wnjtj o^}|itijoti|in|itijoti|innX||_dS(Ni itwbi(t_JSONWriter__datatNonet_JSONWriter__fileobjt_JSONWriter__single_passt_JSONWriter__bufszthashlibtsha1t_JSONWriter__sha_1t_JSONWriter__sha_1_valuet_JSONWriter__signtpathnametostpathtdirnametstatvfstF_BSIZEtEnvironmentErrorterrnotEACCESt api_errorstPermissionsExceptiontfilenametAttributeErrortopentEROFStReadOnlyFileSystemException( tselftdatat single_passRtsigntdest_dirtdestvfstettfile((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyt__init__8sB       cCs|iphSh|id6S(s{Returns a dictionary mapping digest algorithms to the hex-encoded digest values of the text of the catalog.ssha-1(RR (R((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyt signaturesqs sutf-8c Ks_|d|d|d|d|d|d| d| d| | i|d |i} |i| dS( Ntskipkeyst ensure_asciitcheck_circulart allow_nantindentt separatorstencodingtdefaultt _one_shot(t iterencodeRt writelines(RtobjtfpR)R*R+R,tclsR-R.R/R0tkwtiterable((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyt_dumpys   c Csx|i}|p |}n|i|i|dtddd|i|id|io|iin|i p |i o.d|_|io|ii |_ ndSd|_t i |i dtid |_ t|i d |i}|id ti|i}|d jo|idn|id |i|i|dtdd|id|idS(s7Serializes and stores the provided data in JSON format.R+R.t,t:t sort_keyss Nt hash_funcisrb+iis "_SIGNATURE":s} (R:R;(R:R;(RR9RtFalseRtwritetcloseRR t hexdigestR tmisctget_data_digestRR R tfileR tseekRtSEEK_ENDttellR((Rtouttsfiletsfoffset((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pytsaves4           cCs"|io|ii|ndS(sQWrapper function that should not be called by external consumers.N(RR tupdate(RR ((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyR?s cCs%x|D]}|ii|qWdS(sQWrapper function that should not be called by external consumers.N(R RL(RR8tl((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyR3sN(t__name__t __module__t__doc__R>RtTrueR'R(tjsont JSONEncoderR9RKR?R3(((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyR4s9   : tCatalogPartBasecBseZdZeieiBeiBeiBZd Z d Z e Z d ZeZd Zd edZedZdZdZdZdZedZdZed Ze d ZeeeZRS( sA CatalogPartBase object is an abstract class containing core functionality shared between CatalogPart and CatalogAttrs.cCs||_|tii|jot|n||_||_h|_|i p |i ot |_ t i i |_ n|i|_ dS(s%Initializes a CatalogPartBase object.N(t meta_rootRRtbasenametUnrecognizedCatalogParttnameR"R(texistsRQtloadedtdatetimetutcnowt last_modifiedt_CatalogPartBase__last_modified(RRXRUR"((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyR's     cCs t|}|i|iS(N(RRKR((R tf((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyt_gen_signaturess  cCs|iS(N(t_CatalogPartBase__meta_root(R((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyt__get_meta_rootscCsk|ipdSyti|ii}Wn0tj o$}|itijodSnXt i i |S(sA UTC datetime object representing the time the file used to to store object metadata was modified, or None if it does not exist yet.N( RYRRtstatRtst_mtimeRRtENOENTR[tutcfromtimestamp(Rtmod_timeR%((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyt__last_modifieds cCs*|otii|}n||_dS(N(RRtabspathRa(RR((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyt__set_meta_rootscCs|iotii|ioyti|iWqtj o^}|itijot i |i n|iti jot i |i nqXqnh|_t|_d|_dS(scRemoves any on-disk files that exist for the catalog part and discards all content.N(RRRRYtportabletremoveRRRRRRRRR(R>RZRR](RR%((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pytdestroy s   cCs"|iptStii|iS(suA boolean value indicating wheher a file for the catalog part exists at /.(RR>RRRY(R((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyRYs c CsFtii|i|i}yt|d}Wntj o}|itijot i |d|n|iti jot i |i n|itijot i|i nnXyti|}WnGtj o}t i |n%tj o}t i|nXt|_|idh|_|S(saLoad the serialized data for the catalog part and return the resulting structure.trbtlocationt _SIGNATURE(RRtjoinRURXRDRRReRtRetrievalErrorRRRRRRRtloadt ValueErrortInvalidCatalogFileRQRZtpopR((RRotfobjR%tstruct((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyRs(s.   cCs4|i p |i odStii|i|iS(s{The absolute path of the file used to store the data for this part or None if meta_root or name is not set.N(RURXRRRRq(R((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyRJscCst|d|d|id|i}|i|i|_yti|i|iWnjtj o^}|i t i jot i |i n|i t ijot i|i nnX|io5ti|ii}ti|i||fndS(sSerialize and store the transformed catalog part's 'data' in a file using the pathname /. 'data' must be a dict. 'single_pass' is an optional boolean indicating whether the data should be serialized in a single pass. This is significantly faster, but requires that the entire set of data be serialized in-memory instead of iteratively writing it to the target storage object.R!RR"N(RRR"RKR(Rtchmodt_CatalogPartBase__file_modeRRRRRRRRR]tcalendarttimegmt utctimetupletutime(RR R!R_R%tmtime((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyRKSs$   N(RNRORPRctS_IRUSRtS_IWUSRtS_IRGRPtS_IROTHRzRRaR]R>RZRXRQR"R(R't staticmethodR`t_CatalogPartBase__get_meta_rootR^t_CatalogPartBase__set_meta_rootRmtpropertyRYRsRRKRU(((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyRTs&     " %t CatalogPartcBsXeZdZdZdZdeedZeee dZ dddddddZ dZ deee dZ e dZeeee dZe dZddddd Zd Ze d Zd Ze d Ze dZe dZddZedZdddZeee dZdeee dZdedZRS(sxA CatalogPart object is the representation of a subset of the package FMRIs available from a package repository.cCsRh|_||_|idpt|nti||d|d|dS(s!Initializes a CatalogPart object.scatalog.RUR"N(t_CatalogPart__datatorderedt startswithRWRTR'(RRXRURR"((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyR's   csi|oid|}n#fdid|D}|ofd|DS|ofd|DSfd|DS(sWPrivate generator function to iterate over catalog entries. 'last' is a boolean value that indicates only the last entry for each package on a per-publisher basis should be returned. As long as the CatalogPart has been saved since the last modifying operation, or sort() has has been called, this will also be the newest version of the package. 'ordered' is an optional boolean value that indicates that results should sorted by stem and then by publisher and be in descending version order. If False, results will be in a ascending version order on a per-publisher, per-stem basis. 'pubs' is an optional list of publisher prefixes to restrict the results to.tpubsc3s7x0|])}x i|D]}||fVqWqWdS(N(R(t.0tpubtstem(R(s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pys s c3s7x0|])\}}||i||dfVqWdS(iN(R(RRR(R(s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pys s c3sJxC|]<\}}x-ti||D]}|||fVq*WqWdS(N(treversedR(RRRtentry(R(s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pys s  c3sDx=|]6\}}x'i||D]}|||fVq$WqWdS(N(R(RRRR(R(s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pys s  (Rst pkg_namest publishers(RtlastRRtstems((Rs1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyt__iter_entriess       c Cs|p|o|o|pt|o$|i otit|n|ip|in|o%|i\}}}t|}n|ii |h}|i |g}x_|D]W} | d|jo@|pd|||f}nti |ddd|i qqW|dj o |} nh} || d<|i | |io|idt|gn|ptii}n||_h|_| S(sLAdd a catalog entry for a given FMRI or FMRI components. 'metadata' is an optional dict containing the catalog metadata that should be stored for the specified FMRI. The dict representing the entry is returned to callers, but should not be modified. tversionspkg://%s/%s@%st operationtaddt catalog_nametpfmrisN(tAssertionErrort publisherRtAnarchicalCatalogFMRItstrRZRsttupleRt setdefaulttDuplicateCatalogEntryRRtappendRtsorttsetR[R\R]R(( Rtpfmritmetadatatop_timeRRtvertpkg_listtver_listR((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyRs> #          cCsh|_ti|S(scRemoves any on-disk files that exist for the catalog part and discards all content.(RRTRm(R((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyRms c csx}|id|d|d|D]]\}}}tid|d|d|d}|djp|||o||fVqqWdS(sFA generator function that produces tuples of the form (fmri, entry) as it iterates over the contents of the catalog part (where entry is the related catalog entry for the fmri). Callers should not modify any of the data that is returned. 'cb' is an optional callback function that will be executed for each package. It must accept two arguments: 'pkg' and 'entry'. 'pkg' is an FMRI object and 'entry' is the dictionary structure of the catalog entry for the package. If the callback returns False, then the entry will not be included in the results. 'last' is a boolean value that indicates only the last entry for each package on a per-publisher basis should be returned. As long as the CatalogPart has been saved since the last modifying operation, or sort() has has been called, this will also be the newest version of the package. 'ordered' is an optional boolean value that indicates that results should sorted by stem and then by publisher and be in descending version order. If False, results will be in a ascending version order on a per-publisher, per-stem basis. 'pubs' is an optional list of publisher prefixes to restrict the results to. Results are always in catalog version order on a per- publisher, per-stem basis. RRRRXRRN(t_CatalogPart__iter_entriestfmritPkgFmriR( RtcbRRRRRRR_((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pytentriess  c cs|ih}h}x|id|D]}|i|i|d}xj|D]b}|d}tid|d|d|} | i||<|i|g||i| |fqOWq)Wx;t |i dt dD]\} } | || fVqWdS( syA generator function that produces tuples of (version, entries), where entries is a list of tuples of the format (fmri, entry) where entry is the catalog entry for the FMRI) as it iterates over the CatalogPart contents. 'pubs' is an optional list of publisher prefixes to restrict the results to.RRRXRtkeyiN(( RsRRtgetRRRRRtsortedt iteritemsR( RRXRtversionsRRRRtsverRRR((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pytentries_by_versions"     c cs|oXxP|id|d|d|D]0\}}}tid|d|d|dVq&WdSxE|id|d|d|D]%\}}}d|||dfVq~WdS( sA generator function that produces FMRIs as it iterates over the contents of the catalog part. 'last' is a boolean value that indicates only the last fmri for each package on a per-publisher basis should be returned. As long as the CatalogPart has been saved since the last modifying operation, or sort() has has been called, this will also be the newest version of the package. 'objects' is an optional boolean value indicating whether FMRIs should be returned as FMRI objects or as strings. 'ordered' is an optional boolean value that indicates that results should sorted by stem and then by publisher and be in descending version order. If False, results will be in a ascending version order on a per-publisher, per-stem basis. 'pubs' is an optional list of publisher prefixes to restrict the results to. Results are always in catalog version order on a per- publisher, per-stem basis.RRRRXRRNspkg://%s/%s@%s(RRR(RRtobjectsRRRRR((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pytfmris5s  c cs|ih}h}x|id|D]}|i|i|d}|pq)nxd|D]\}|d}tid|d|d|} | i||<|i|g||i | q]Wq)Wx;t |i dt dD]\} } | || fVqWdS(sA generator function that produces tuples of (version, fmris), where fmris is a list of the fmris related to the version. 'pubs' is an optional list of publisher prefixes to restrict the results to.RRRXRRiN( RsRRRRRRRRRRRR( RRXRRRRRRRRRR((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pytfmris_by_version[s&     cCs|p|o|o|pt|o$|i otit|n|ip|in|o%|i\}}}t|}n|ii |d}|pdS|i |d}x$|D]}|d|jo|SqWdS(s]Returns the catalog part entry for the given package FMRI or FMRI components.NR(( RRRRRRZRsRRRR(RRRRRRRR((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyt get_entryxs # cCst|id}d}xQ|iD]C}x:|i|D]+}|d7}|t|i||7}q7Wq#W||fS(sReturns a tuple of integer values (package_count, package_version_count). The first is the number of unique packages (per-publisher), and the second is the number of unique package versions (per-publisher and stem).ii(RsRRtlen(Rt package_counttpackage_version_countRR((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pytget_package_countss    ccs|ixq|id|D]]}d}d}x:|i|D]+}|d7}|t|i||7}q=W|||fVqWdS(scReturns a generator of tuples of the form (pub, package_count, package_version_count). 'pub' is the publisher prefix, 'package_count' is the number of unique packages for the publisher, and 'package_version_count' is the number of unique package versions for the publisher. RiiN(RsRRR(RRRRRR((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pytget_package_counts_by_pubs  cCs%|iodSti||_dS(sQLoad and transform the catalog part's data, preparing it for use.N(RZRTRsR(R((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyRss cs0itfdid|DS(sReturns a set containing the names of all the packages in the CatalogPart. 'pubs' is an optional list of publisher prefixes to restrict the results to.c3s1x*|]#}xi|D] }|VqWqWdS(N(R(RRR(R(s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pys s R(RsRR(RR((Rs1/usr/lib/python2.6/vendor-packages/pkg/catalog.pytnamess  c #s|ig}|id|D]+}|i|D]}|d||fq2q!~}d}|o5tdt|Dfd}|}nx=t|d|D])}|idd\}}||fVqWdS( sA generator function that produces package tuples of the form (pub, stem) as it iterates over the contents of the CatalogPart. 'pubs' is an optional list of publisher prefixes to restrict the results to. If specified, publishers will be sorted in the order given. Results are always returned sorted by stem and then by publisher.Rs%s!%scss%x|]\}}||fVqWdS(N((Rtitp((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pys s csf|idd\}}|idd\}}t||}|djo|St||S(Nt!ii(tsplittcmp(tatbtastemtapubtbstemtbpubtres(tpos(s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pytpos_sorts  RRiN(RsRRRtdictt enumerateRR( RRt_[1]RRRtpub_sortRR((Rs1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyRs . ccsR|ixA|iD]6}|ddj o| p ||jo |VqqWdS(sA generator function that returns publisher prefixes as it iterates over the package data in the CatalogPart. 'pubs' is an optional list that contains the prefixes of the publishers to restrict the results to.it_N(RsR(RRR((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyRs   'cCs5|ipti|in|i|ii|id}|pti|int |i }|i|i g}xyt |D]V\}}|d|jo9||=|p||i =n|p|i|i=nPqqWti|i|pt i i}n||_h|_dS(s"Remove a package and its metadata.RN(RRRtget_fmriRsRRRtUnknownCatalogEntryRRtpkg_nameRR[R\R]R((RRRRRRRR((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyRls,     cCs6|ipdS|iti||id|dS(sTransform and store the catalog part's data in a file using the pathname /. 'single_pass' is an optional boolean indicating whether the data should be serialized in a single pass. This is significantly faster, but requires that the entire set of data be serialized in-memory instead of iteratively writing it to the target storage object.NR!(RURsRTRKR(RR!((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyRK$s  c Csd}|i|dj ot}x|D]}|i}||joq0n|i||ii|id}|o4|i|id}|o|i d|qq0q0WdSxM|i d|D]9} x0|i| D]!} |i| | i d|qWqWdS(sRe-sorts the contents of the CatalogPart such that version entries for each package stem are in ascending order. 'pfmris' is an optional set of FMRIs to restrict the sort to. This is useful during catalog operations as only entries for the corresponding package stem(s) need to be sorted. 'pubs' is an optional set of publisher prefixes to restrict the sort to. This is useful during catalog operations as only entries for the corresponding publisher stem(s) need to be sorted. This option has no effect if 'pfmris' is also provided. If neither 'pfmris' or 'pubs' is provided, all entries will be sorted.cSs?tii|dd}tii|dd}t||S(NRs5.11(tpkgRtVersionR(RRtv1tv2((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pytorderHsRNR( RsRRt get_pkg_stemRRRRRRR( RRRRt processedR_tpkg_stemRRRR((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyR7s,         cCs&d|id|d|d|DS(sA generator function that produces FMRI tuples as it iterates over the contents of the catalog part. 'last' is a boolean value that indicates only the last FMRI tuple for each package on a per-publisher basis should be returned. As long as the CatalogPart has been saved since the last modifying operation, or sort() has has been called, this will also be the newest version of the package. 'ordered' is an optional boolean value that indicates that results should sorted by stem and then by publisher and be in descending version order. If False, results will be in a ascending version order on a per-publisher, per-stem basis. 'pubs' is an optional list of publisher prefixes to restrict the results to.css/x(|]!\}}}|||dfVqWdS(RN((RRRR((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pys zs RRR(R(RRRR((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyttuplesfsc csuxn|id|d|d|D]N\}}}|||df}|djp|||o||fVqqWdS(sTA generator function that produces tuples of the form ((pub, stem, version), entry) as it iterates over the contents of the catalog part (where entry is the related catalog entry for the fmri). Callers should not modify any of the data that is returned. 'cb' is an optional callback function that will be executed for each package. It must accept two arguments: 'pkg' and 'entry'. 'pkg' is an FMRI tuple and 'entry' is the dictionary structure of the catalog entry for the package. If the callback returns False, then the entry will not be included in the results. 'last' is a boolean value that indicates only the last entry for each package on a per-publisher basis should be returned. As long as the CatalogPart has been saved since the last modifying operation, or sort() has has been called, this will also be the newest version of the package. 'ordered' is an optional boolean value that indicates that results should sorted by stem and then by publisher and be in descending version order. If False, results will be in a ascending version order on a per-publisher, per-stem basis. 'pubs' is an optional list of publisher prefixes to restrict the results to. Results are always in catalog version order on a per-publisher, per-stem basis.RRRRN(RR( RRRRRRRRtt((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyt tuple_entriess  cCsw|i o| o | odS|i|p |i}n|i|i}||joti|indS(sVerifies whether the signatures for the contents of the CatalogPart match the specified signature data, or if not provided, the current signature data. Raises the exception named 'BadCatalogSignatures' on failure.N(R(RsR`RRtBadCatalogSignaturesR(RR(trequire_signaturestnew_signatures((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pytvalidates   N(RNRORPRRRRQR'R>RRRRmRRRRRRRRsRRRRlRKRRRR(((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyR{s2 . 2 & &     %  % /%t CatalogUpdatecBsteZdZd Zd ZdZdZd edZ d dZ dZ dZ dZ dZd ed ZRS( syA CatalogUpdate object is an augmented representation of a subset of the package data contained within a Catalog.RRlcCsIh|_|idpt|nti||d|d|dS(s#Initializes a CatalogUpdate object.supdate.RUR"N(t_CatalogUpdate__dataRRWRTR'(RRXRUR"((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyR's  cCs |ipti|in||i|ifjoti|n|i|ii |ih|i|i}|i |i g||i }|dj o |}nh}t ||d<||d/.N(RURsRTRKR(R((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyRKs  ccss|id}xY|iD]K}xB|i|D]3}x*|i||D]}||||VqLWq4Wq WdS(sA generator function that produces tuples of the format (fmri, op_type, op_time, metadata). Where: * 'fmri' is a PkgFmri object for the package. * 'op_type' is a CatalogUpdate constant indicating the catalog operation performed. * 'op_time' is a UTC datetime object representing the time time the catalog operation was performed. * 'metadata' is a dict containing the catalog metadata for the FMRI indexed by catalog part name. Results are always in ascending operation time order on a per-publisher, per-stem basis. c Ssh}x0|D](}|ido||||R(((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyRs - %t CatalogAttrscBskeZdZdZhdd6dd6dd6dd6hd6hd6dd 6Zded Zd Zd Z d Z dZ dZ dZ dZdZdZdZdZdZdZdZdZdZdZdedZeeeZee eZee eZee eZee eZ ee eZ!eeeZ"RS(sZA CatalogAttrs object is the representation of the attributes of a Catalog object.tcreateds last-modifiedis package-countspackage-version-counttpartsRiRcCsh|_ti|ddd|d||io@|id}ti|i|_||id<||id/.NR!(RURsRTRKt_CatalogAttrs__transformRQ(R((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyRKs  cCsz|i o| o | odS|i|p |i}n|i|i}||joti|indS(sVerifies whether the signatures for the contents of the CatalogAttrs match the specified signature data, or if not provided, the current signature data. Raises the exception named 'BadCatalogSignatures' on failure.N(R(RsR`RRRR(RR(RR((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyR s   N(#RNRORPRRRRQR't_CatalogAttrs__get_createdt _CatalogAttrs__get_last_modifiedt _CatalogAttrs__get_package_countt(_CatalogAttrs__get_package_version_countt_CatalogAttrs__get_partst_CatalogAttrs__get_updatest_CatalogAttrs__get_versiont_CatalogAttrs__set_createdt _CatalogAttrs__set_last_modifiedt _CatalogAttrs__set_package_countt(_CatalogAttrs__set_package_version_countt_CatalogAttrs__set_partst_CatalogAttrs__set_updatest_CatalogAttrs__set_versionRRsRKR>RRRR]RRRRR(((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyRXsJ                 7  tCatalogcBsXeZdZdZdZdZeieiBei Bei BZ e Z e Ze Ze Ze Ze Ze Ze Zed\ZZee ee eedZee e eeedZe e edZe eee eeedZe e ed Ze ed Z!eed Z"e d Z#d Z$dZ%dZ&dZ'eedZ(dZ)dZ*e dZ+e dZ,dZ-dZ.dZ/dZ0dZ1dZ2dZ3dZ4ee ee eedZ5e e dZ6e e ed Z7d!Z8eed"Z9e:d#Z;d$Z<eee eed%Z=ee ed&Z>ee ee eed'Z?e:d(Z@e e d)ZAeeeed*ZBed+ZCee d,ZDee d-ZEd.ZFd/ZGd0ZHee eee ed1ZId2ZJed3ZKed4ZLd5ZMed6ZNe:d7ZOe:d8ZPe:d9ZQed:ZRd;ZSd<ZTd=ZUe:d>ZVeeed?ZWeee eed@ZXe:dAZYe e e e dBZZedCZ[e:e$e.Z\e:e%e/dDdEZ]e:e&e0Z^e:e'e2Z_e:e)e3Z`RS(FsaA Catalog is the representation of the package FMRIs available from a package repository.scatalog.base.Cscatalog.dependency.Cscatalog.summaryicCs||_||_h|_h|_||_||_||_||_td|id||_ t i |_ |i dS(s9Initializes a Catalog object. 'batch_mode' is an optional boolean value that indicates that the caller intends to perform multiple modifying operations on catalog before saving. This is useful for performance reasons as the contents of the catalog will not be sorted after each change, and the package counts will not be updated (except at save()). By default this value is False. If this value is True, callers are responsible for calling finalize() to ensure that catalog entries are in the correct order and package counts accurately reflect the catalog contents. 'meta_root' is an optional absolute pathname of a directory that catalog metadata can be written to and read from, and must already exist. If no path is supplied, then it is assumed that the catalog object will be used for in-memory operations only. 'log_updates' is an optional boolean value indicating whether updates to the catalog should be logged. This enables consumers of the catalog to perform incremental updates. 'manifest_cb' is an optional callback used by actions() and get_entry_actions() to lazy-load Manifest Actions if the catalog does not have the actions data for a requested package entry. 'read_only' is an optional boolean value that indicates if operations that modify the catalog are allowed (an assertion error will be raised if one is attempted and this is True). 'sign' is an optional boolean value that indicates that the the catalog data should have signature data generated and embedded when serialized. This option is primarily a matter of convenience for callers that wish to trade integrity checks for improved catalog serialization performance.RUR"N(t_Catalog__batch_modet_Catalog__manifest_cbt_Catalog__partst_Catalog__updatest log_updatesRUt read_onlyR"Rt_attrst threadingtLockt_Catalog__lockt_Catalog__set_perms(Rt batch_modeRUR%t manifest_cbR&R"((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyR'Ms&        c cs|pt|ptd }n t|}x|id|d|d|d|d|d|D]z\}} y"||i|| d|fVWqbtj o=|io!||i||||fVq|tfVqbXqbWdS( NtCRt info_neededtlocalest last_versionRRtactions(R.(RRt_Catalog__entriest_Catalog__gen_actionstKeyErrorR"t_Catalog__gen_lazy_actionsR( RR/texcludesRR0R1RRR_R((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyt __actionss      c Cs@|i|i}|i|idt}|djo|oti|ndStii}|oH|i|}|djoti|i n||fg} n |i } h} x| D]\} }|o| i |joqnt i |} |dj o||| |\} }| pD| i| i h}|i| it}|i| iqn|o0d| jo| di|q|| dR'R]R%RRtdatetime_to_update_tsRt_Catalog__get_updateRRR#R(RRRRRRXRtpnameRNRtlogdateRRXRnRC((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyt __log_updates4        c csd}x|D]}d }d }d }yB|idd}|d}d }t|djo|d}nd|jp d|jo ti}n7|idp|ido ti}n ti}|tijoti||}nti ||}|pn\d|jpd|jp |d jot i i |||_ nt i i |||_ Wn*tit i ifj o} | }nX||||fVq Wd S( sA generator function that yields a list of tuples of the form (pattern, error, fmri, matcher) based on the provided patterns, where 'error' is any exception encountered while parsing the pattern, 'fmri' is the resulting FMRI object, and 'matcher' is one of the following pkg.fmri matching functions: pkg.fmri.exact_name_match Indicates that the name portion of the pattern must match exactly and the version (if provided) must be considered a successor or equal to the target FMRI. pkg.fmri.fmri_match Indicates that the name portion of the pattern must be a proper subset and the version (if provided) must be considered a successor or equal to the target FMRI. pkg.fmri.glob_match Indicates that the name portion of the pattern uses fnmatch rules for pattern matching (shell- style wildcards) and that the version can either match exactly, match partially, or contain wildcards. s5.11t@iit*t?spkg:/t/tlatestN(RRRRt glob_matchRtexact_name_matcht fmri_matchtMatchingPkgFmriRRRtMatchingVersionRt FmriErrort VersionError( tpatternstbreleasetpatterrortmatchertnpatRtpat_stemtpat_verR%((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyt__parse_fmri_patternssD            c Cs)|i}|iowxt|iiD]_\}}|ih|id6}|i|n|d} || joq>n|tijo|i|d|d|q>|tijo|i |d|q>t i |q>WqWdS(NRUR9s last-modifiedRR( RRRR:RQRRRRRlRR( RXRnRtop_typeRRRvtpdataRCR (RRt old_parts(s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pytapply_incrementals(         csAtii|}tiii|}ti||dS(N(RRRqRURktcopyfile(RXR<RF(RR(s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyt apply_fullsNsupdate.RUs signature-iR((RURtCatalogUpdateRequirementsR'RRR,RQtget_updates_neededRRRRRtfinalizeR#Rt_Catalog__saveRXR+R( RRRRRRRXt new_attrstnew_sigsRRtsigRC((RRRs1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyt apply_updatessN             cCs;|i|igd|dtd|}td|DS(sReturns a set of tuples of the form (scheme, category) containing the names of all categories in use by the last version of each unique package in the catalog on a per- publisher basis. 'excludes' is a list of variants which will be used to determine what category actions will be checked. 'pubs' is an optional list of publisher prefixes to restrict the results to.R7R1RcssXxQ|]J\}}x;|D]3}|io x|iD] }|Vq9WqqWqWdS(N(thas_category_infotparse_category_info(RR_RRtsc((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pys 2 s   (RRLRQR(RR7RR((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyt categories# s cCs |iiS(sRA UTC datetime object indicating the time the catalog was created.(R'R(R((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyR9 sc Csx-|iiD]}|i|}|iq Wx3|iiD]%}|i|dt}|iq=Wtd|id|i |_h|_ h|_ |ii|i pt i i|i odSxt i|iD]}|id o|id oqnt i i|i|}t i i|pqnyti|Wqtj o^}|itijoti|in|itijoti|inqXqWdS(s^Removes any on-disk files that exist for the catalog and discards all content.RmRUR"Nscatalog.supdate.(R'RR:RmRRuR>RRURkR#R$RRRYtlistdirRRqtisfileRkRlRRRRRRRR(RRXRCRntfnameRvR%((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyRm? sB     "c Cs(|id|d|d|d|d|S(s A generator function that produces tuples of the format (fmri, metadata) as it iterates over the contents of the catalog (where 'metadata' is a dict containing the requested information). 'metadata' always contains the following information at a minimum: BASE 'metadata' will be populated with Manifest signature data, if available, using key-value pairs of the form 'signature-': value. 'info_needed' is an optional list of one or more catalog constants indicating the types of catalog data that will be returned in 'metadata' in addition to the above: DEPENDENCY 'metadata' will contain depend and set Actions for package obsoletion, renaming, variants, and facets stored in a list under the key 'actions'. SUMMARY 'metadata' will contain any remaining Actions not listed above, such as pkg.summary, pkg.description, etc. in a list under the key 'actions'. 'last' is a boolean value that indicates only the last entry for each package on a per-publisher basis should be returned. As long as the catalog has been saved since the last modifying operation, or finalize() has has been called, this will also be the newest version of the package. 'locales' is an optional set of locale names for which Actions should be returned. The default is set(('C',)) if not provided. Note that unlike actions(), catalog entries will not lazy-load action data if it is missing from the catalog. 'ordered' is an optional boolean value that indicates that results should sorted by stem and then by publisher and be in descending version order. If False, results will be in a ascending version order on a per-publisher, per-stem basis. 'pubs' is an optional list of publisher prefixes to restrict the results to.R/R1R0RR(R3(RR/RR0RR((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyRk s3c cs|i|idt}|djodS|ptd}n t|}g}|i|jo:|i|idt}|dj o|i|qn|i|joXxU|D]I}|id|i |fdt}|djoqn|i|qWnd} x|i |d|D]\} } g} x{| D]s\} }h}| ||x>|D]6}|i | }|djoqcn| ||qcW| i| |fq=W| | fVq$WdS(sA generator function that produces tuples of the format (version, entries) as it iterates over the contents of the the catalog, where entries is a list of tuples of the format (fmri, metadata) and metadata is a dict containing the requested information. 'metadata' always contains the following information at a minimum: BASE 'metadata' will be populated with Manifest signature data, if available, using key-value pairs of the form 'signature-': value. 'info_needed' is an optional list of one or more catalog constants indicating the types of catalog data that will be returned in 'metadata' in addition to the above: DEPENDENCY 'metadata' will contain depend and set Actions for package obsoletion, renaming, variants, and facets stored in a list under the key 'actions'. SUMMARY 'metadata' will contain any remaining Actions not listed above, such as pkg.summary, pkg.description, etc. in a list under the key 'actions'. 'locales' is an optional set of locale names for which Actions should be returned. The default is set(('C',)) if not provided. 'pubs' is an optional list of publisher prefixes to restrict the results to.R9NR.s%s.%scSsmxf|iD]X\}}|djo$|i|g||c|7|D]6} | i|} | djoqIn|| |qIW|S(s@Returns a dict containing the metadata for the specified FMRI containing the requested information. If the specified FMRI does not exist in the catalog, a value of None will be returned. 'metadata' always contains the following information at a minimum: BASE 'metadata' will be populated with Manifest signature data, if available, using key-value pairs of the form 'signature-': value. 'info_needed' is an optional list of one or more catalog constants indicating the types of catalog data that will be returned in 'metadata' in addition to the above: DEPENDENCY 'metadata' will contain depend and set Actions for package obsoletion, renaming, variants, and facets stored in a list under the key 'actions'. SUMMARY 'metadata' will contain any remaining Actions not listed above, such as pkg.summary, pkg.description, etc. in a list under the key 'actions'. 'locales' is an optional set of locale names for which Actions should be returned. The default is set(('C',)) if not provided. cSsmxf|iD]X\}}|djo$|i|g||c|7K s  N(RRRRRR(RRR((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pytget_entry_signatures@ s  cCs6x/|i|D]\}}||jo|SqWdS(sA generator function that returns the variants for the specified variant name. If no variants exist for the specified name, None will be returned.N(RR(RRRXtvar_nameRR((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pytget_entry_variantsP s    c-#sd}t}g} h} t} t} t} x|i|D]\}}}}|o| i|qCnt|}|| joqCn| i|| i|t|iddo| i|n|i |f| |\}}}|\}}}t}d}di||f}|o||jo t}n||cd7<|dj p |dj o t}n|p"d} x|D] }| |\\}!}"}#}|!dj o+||!jo|djo t}qqn|tijo/|"|jo|djo t}qqq3n|tijo:d|id|"p|djo t}qqq3nF|tijo5ti||"p|djo t}qqq3n|#dj og| djotii||} n| i|#tiip$|djo t}nt}qqn|| jo5||djo$|djo t}nt}qnt}|djo|djoPn|i|qWn|oqfnd}$t}%t}&|od }'t i |'}(nt }(yex^|D]Vi!d joqyni"d })i"d }*|oMi#d }+tfd i"i$D},|(|)|,i%|+n|)djo |*}$qyn|)djo:|$djo&|*}$|o|(d|,i%|+qyqyn|)djo(|*djo|&it&i'qyqyn|)djo(|*djo|&it&i(qyqyqyqyWWn&t i)j o|&it&i*nX|o*|o||djo ||=qfqfn|dj p |dj o|i+|n|o6ti,d|d |d|d|}||&|(fVqf||&|(fVqfW|dj o|i+|n|dj o!|i+t| i-|ndS(sA generator function that produces tuples of the form: ( ( pub, - (string) the publisher of the package stem, - (string) the name of the package version - (string) the version of the package ), states, - (list) states attributes - (dict) package attributes ) Results are always sorted by stem, publisher, and then in descending version order. 'collect_attrs' is an optional boolean that indicates whether all package attributes should be collected and returned in the fifth element of the return tuple. If False, that element will be an empty dictionary. 'matched' is an optional set to add matched patterns to. 'patterns' is an optional list of FMRI wildcard strings to filter results by. 'pubs' is an optional list of publisher prefixes to restrict the results to. 'unmatched' is an optional set to add unmatched patterns to. 'return_fmris' is an optional boolean value that indicates that an FMRI object should be returned in place of the (pub, stem, ver) tuple that is normally returned.s5.11t match_latesttillegalRRRiR|cSs titS((t collectionst defaultdicttlist(((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyt sRRXRc3s?x8|]1}|djo|ti|fVqqWdS(RXRN(snamesvalue(t frozensettattrlist(RRG(R(s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pys . s s pkg.summaryt descriptions pkg.renamedttrues pkg.obsoletet build_releaseRRN(.R>Rt_Catalog__parse_fmri_patternsRRRtgetattrRRRRtPackageMatchErrorsRRtintRRJRLRRQRqRRRtendswithR~tfnmatcht fnmatchcaseRRt is_successortCONSTRAINT_AUTORRXRXRtiterkeysRtpkgdefstPKG_STATE_RENAMEDtPKG_STATE_OBSOLETERZtPKG_STATE_UNSUPPORTEDRLRR(-Rt collect_attrstmatchedRRt unmatchedt return_fmrisRtnewesttillegalst pat_tuplest latest_patstseent npatternsRRRRtsfmritnlistt matched_patstpkg_matching_patstcat_infoRRR2RRRtomit_vert omit_packageRtevertpat_pubRRtsummtomit_vartstatestddmRXtatnametatvaluetatvlisttmods((Rs1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyt gen_packages\ s,$                                                            c+Cscg}t}g}g}g}t}d}t} t} t} x|i|D]\} } }}| o|i| q[nt|}|| joq[n| i|| i| d|ijpd|ijo|i| nt|idd o| i| n|i| ||fq[W| }~ ~ |ot i d|nt t |g}|D]}|t qq~}x|i D]}x|D]\} }}|i}|i}|||ipqnx|i|D]\}}|o!|i|tii oqnxX|D]P\}}|i}|o||joq0n|| i|igi|q0WqWqWqW| oh}h}x|D]}|| jp || o||||RRRRLRR;RKRRMRR(RRRt old_attrsRt incrementalRXtold_lmtnew_lmRNRwtlognameR0Rtlast_lmR tuattrstup_lmt up_locale((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyRc s                  cCs=|i|idt}|djotS|id|S(sReturns a set containing the names of all the packages in the Catalog. 'pubs' is an optional list of publisher prefixes to restrict the results to.R9RN(R:R;RQRRR(RRR=((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyR s cCs |iiS(s-The number of unique packages in the catalog.(R'R(R((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyRscCs |iiS(s5The number of unique package versions in the catalog.(R'R(R((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyRscCs |iiS(sA dict containing the list of CatalogParts that the catalog is composed of along with information about each part.(R'R(R((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyR scCs@|i|idt}|djo tdS|id|S(sA generator function that produces package tuples of the form (pub, stem) as it iterates over the contents of the catalog. 'pubs' is an optional list that contains the prefixes of the publishers to restrict the results to.R9RN((R:R;RQRRR(RRR=((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyRs  cCsG|i|idt}|djotStd|iDS(s[Returns a set containing the prefixes of all the publishers in the Catalog.R9cssx|] }|VqWdS(N((RR((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pys +s N(R:R;RQRRR(RR=((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyR#s c Cs|i pt|izh}tii}x|iiD]}|i|}|djoqAn|i |}|djo0||i jot i |i qAqAn|i|d||io|||i': value. 'info_needed' is an optional list of one or more catalog constants indicating the types of catalog data that will be returned in 'metadata' in addition to the above: DEPENDENCY 'metadata' will contain depend and set Actions for package obsoletion, renaming, variants, and facets stored in a list under the key 'actions'. SUMMARY 'metadata' will contain any remaining Actions not listed above, such as pkg.summary, pkg.description, etc. in a list under the key 'actions'. 'last' is a boolean value that indicates only the last entry for each package on a per-publisher basis should be returned. As long as the catalog has been saved since the last modifying operation, or finalize() has has been called, this will also be the newest version of the package. 'locales' is an optional set of locale names for which Actions should be returned. The default is set(('C',)) if not provided. Note that unlike actions(), catalog entries will not lazy-load action data if it is missing from the catalog. 'ordered' is an optional boolean value that indicates that results should sorted by stem and then by publisher and be in descending version order. If False, results will be in a ascending version order on a per-publisher, per-stem basis. 'pubs' is an optional list of publisher prefixes to restrict the results to.R/R0R1RRR(R3RQ(RR/RR0RR((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyRs3cCs |iiS(suA dict containing the list of known updates for the catalog along with information about each update.(R'R(R((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyRsc Cs|p|o|o|pt|i o |i pt|i|idt}|d joB|p"tid|d|d|}nt i |i n|i d|d|d|d|}|d joB|p"tid|d|d|}nt i |i n|d jod |jo |d =nd S||d }|idpq n|idd}||||(RRR#RXRRCRn((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyRs"       tdocsHA UTC datetime object indicating the last time the catalog was modified.(aRNRORPR;RKRMRcRRRRRRR'R!R*R"RjRkR#R$trangeRJRLR>RQR'RRRR3RsRR4R6R`t_Catalog__get_batch_modet_Catalog__get_last_modifiedt_Catalog__get_meta_roott_Catalog__get_signRut_Catalog__get_versionRRRRt_Catalog__set_batch_modet_Catalog__set_last_modifiedt_Catalog__set_meta_rootR+t_Catalog__set_signt_Catalog__set_versionRR2RRRRRRRmRRRRYRRRRRRRRRRRR:RRRRRRRRRKR(RRRR"RR,R]RUR"R(((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyR /s : Z  L& &       -I +    -   Bm+ a , 6 WQ ! V 3     *   )  6  4 %  cCstii|\}}d}|ido9|idotd|}qt|d|}n6|idot|d|}nt i ||pt |i dt dS(sConvert the catalog part named by filename into the correct type of Catalog object and then call its validate method to ensure that is contents are self-consistent.tcatalogRXRURLRN(RRRRRRRRRRRWRRRQ(RRtfntcatobj((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pytverify4scCs |iS(sLTake datetime object dt, and convert it to a ts in ISO-8601 format. (t isoformat(tdt((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pytdatetime_to_tsMscCsO|i}|idd}|idd}|ip|d7}n|S(sRTake datetime object dt, and convert it to a ts in ISO-8601 basic format. t-tR;tZ(R4treplacettzname(R5R((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyRSs   cCse|i}|idd}|iddd}|idd}|ip|d7}n|S(sZTake datetime object dt, and convert it to a ts in ISO-8601 basic partial format. R7R8R;iiR9(R4R:trsplitR;(R5R((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyRt`s  cCsttiiS(sKReturns the current UTC time as timestamp in ISO-8601 basic format.(RR[R\(((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pytnow_to_basic_tsoscCsttiiS(sSReturns the current UTC time as timestamp in ISO-8601 basic partial format.(RtR[R\(((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pytnow_to_update_tstscCst|dd!}t|dd!}t|dd!}t|dd!}t|d d !}t|d d !}yt|d d!}Wntj o d}nXti|||||||S(sRTake timestamp ts in ISO-8601 format, and convert it to a datetime object.iiiiii i i iiiiii(RRtR[(ttstyeartmonthtdaythourtminutestsectusec((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pytts_to_datetimeys cCst|dd!}t|dd!}t|dd!}t|dd!}t|dd!}t|dd!}yt|d d !}Wntj o d}nXti|||||||S( sXTake timestamp ts in ISO-8601 basic format, and convert it to a datetime object.iiiii i i iii(RRtR[(R?R@RARBRCRDRERF((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyRs (0RPRR{RR[RRR Rt simplejsonRRRcRR(R t pkg.actionsRtpkg.client.api_errorstclientRtpkg.client.pkgdefsRtpkg.fmriRtpkg.miscRBt pkg.portableRkt pkg.versiontoperatorRRRtobjectRRTRRRR R3R6RRtR=R>RGR(((s1/usr/lib/python2.6/vendor-packages/pkg/catalog.pyts`               A