#Tc@sddlmZmZddlZddlZddlZddlZddlZddlZddl m Z m Z m Z m Z mZddlmZddljZddljjZddljZddljZddljZddljZddlj Z ddl!j"Z"ddlm#Z#m$Z$m%Z%m&Z&m'Z'ddl(m)Z)ddl*m+Z+dZ,d Z-d ed d fd YZ.d e/fdYZ0e0Z1de0fdYZ2de0fdYZ3e3Z4de5fdYZ6dS(i(t namedtuplet defaultdictN(tgroupbytchaintproducttrepeattizip(t itemgetter(t EmptyDicttEmptyIt expanddirst PKG_FILE_MODEt PKG_DIR_MODE(tAttributeAction(tDirectoryActioncCstd|jDS(sdPrivate helper function that returns a compiled version of a dictionary of fnmatch patterns.cssO|]E\}}|g|D]'}tjtj|tjj^qfVqdS(N(tretcompiletfnmatcht translatet IGNORECASEtmatch(t.0tkeytpatstpat((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pys 7s(tdictt iteritems(tfn_pats((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyt_compile_fnpats2scCsx|s tSxg|jD]Y\}}||jkrx;|D]0}x'|j|D]}||rOtSqOWq9WqqWtS(sPrivate helper function: given an action, return True if any of its attributes' values matches the pattern for the same attribute in the attr_match dictionary, and False otherwise. Note that the patterns must be pre-comiled using re.compile() or _compile_fnpats.(tTrueRtattrstattrlisttFalse(tactiont attr_matchtattrtmatchesRtattrval((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyt _attr_matches?s  tManifestDifferencesadded changed removedcBseZgZeejjejjfgejjejjfgejjejjfggZeejjgZ e ddZ e ddZ RS(cCs.tjtjt|tjdtjd|S(sReturns the serialized state of this object in a format that that can be easily stored using JSON, pickle, etc.t commonizetje_state(tmisct json_encodeR't__name__ttuplet _ManifestDifference__state__desct%_ManifestDifference__state__commonize(tobjR)((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pytgetstate`s     cCs4tjtj|tjdtjd|}t|S(s`Allocate a new object using previously serialized state obtained via getstate().R(tjd_state(R*t json_decodeR'R,R.R/(tstateR2((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyt fromstatejs     N(R,t __module__t __slots__R-tactionstgenerictNSGR.t frozensetR/t staticmethodtNoneR1R5(((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyR'Qs! tManifestcBseZdZd(dZdZdZdZeedZ e dZ eedZ eedZ d Zd Zd Zd Zd ZeedZeedZedZd(edZd(edZd(edZedZedZdZd(ed(edZdZdZdZ e ed(dZ!e dZ"dZ#dZ$dZ%d Z&d!Z'd"Z(ed#Z)ed$Z*d%Z+d&Z,d'Z-RS()sA Manifest is the representation of the actions composing a specific package version on both the client and the repository. Both purposes utilize the same storage format. The serialized structure of a manifest is an unordered list of actions. The special action, "set", represents a package attribute. The reserved attribute, "fmri", represents the package and version described by this manifest. It is available as a string via the attributes dictionary, and as an FMRI object from the fmri member. The list of manifest-wide reserved attributes is base_directory Default base directory, for non-user images. fmri Package FMRI. isa Package is intended for a list of ISAs. platform Package is intended for a list of platforms. relocatable Suitable for User Image. All non-prefixed attributes are reserved to the framework. Third parties may prefix their attributes with a reversed domain name, domain name, or stock symbol. An example might be com.example,supported as an indicator that a specific package version is supported by the vendor, example.com. manifest.null is provided as the null manifest. Differences against the null manifest result in the complete set of attributes and actions of the non-null manifest, meaning that all operations can be viewed as tranitions between the manifest being installed and the manifest already present in the image (which may be the null manifest). cCs||_i|_g|_g|_i|_i|_t|_t|_ |dk rt |tj s~tj |dd}n|j |_ n d|_ dS(Nt build_releases5.11(tfmrit_cachet _absent_cacheR8tactions_bytypet attributesRt signaturesR texcludesR=t isinstancetPkgFmrit publisher(tselftpfmri((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyt__init__s           cCsdd}d|jkr8|jdkr8|d|j7}nx%t|jD]}|d|7}qHW|S(Ntspkg.fmrisset name=pkg.fmri value=%s s%s (RDR@R=tsortedR8(RJtrtact((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyt__str__s ccsNd|jkr-|jdkr-d|jVnx|jD]}d|Vq7WdS(sbA generator function that returns the unsorted manifest contents as lines of text.spkg.fmrisset name=pkg.fmri value=%s s%s N(RDR@R=R8(RJRP((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pytas_linesscCsdjd|jDS(NRMcss|] }|VqdS(N((Rtl((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pys s(tjoinRR(RJ((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyttostr_unsortedscst|trDtg|jd|D]}d|f^q%ggSdfd}t|||}t|||}t|j}t|j} g|| D]} d|| f^q} g| |D]} || df^q} g| |@D]1} || j|| r|| || f^q} t d}t d}| j d|dt | j d|| j d|t| | | S( sReturn three lists of action pairs representing origin and destination actions. The first list contains the pairs representing additions, the second list contains the pairs representing updates, and the third list contains the pairs representing removals. All three lists are in the order in which they should be executed.RFcSs t|tk r|St|S(s#handle key values that may be lists(ttypetlistR-(tv((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pythashifysc3sx|jd|D]}|jdks7|jdkr|jjdr|jt|j|j|jjd|jjdgf}n-|j|jj|jt|f}||fVqWdS(NRFtlinkthardlinktmediatorsmediator-versionsmediator-implementation(t gen_actionstnameRtgetR-tkey_attrtid(tmfRFtatakey(RY(s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pytdictifys  iiRtreverseN( RGtEmptyFactoredManifestR'R]R=Rtsettiterkeyst differentRtsortR(RJtorigintorigin_excludet self_excludeRcRetsdicttodicttssettosettitaddedtremovedtchangedtaddsorttremsort((RYs2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyt differences*  & ''1  c s2|s tg}g}x|D]}i}x|jD]yOtjj}|jfdjdDt|}Wn tk rt f}nX|j j |fkr8|j |j |ffq8q8W|j |qW|r!t d|ng|D]}t|j^q(}td|}xi|jD][}xRtt|dD]:} || |j|| d|r|j|PqqWqeWtgtt|D]/} g|| |D]}|| |^q^qg|D]}|d|^qgS(sRLike the unix utility comm, except that this function takes an arbitrary number of manifests and compares them, returning a tuple consisting of each manifest's actions that are not the same for all manifests, followed by a list of actions that are the same in each manifest.c3s&|]}d|j|fVqdS(s%s=%sN(R(RRX(Rc(s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pys %sit duplicatescSs||@S(N((Rctb((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyt>si(tAssertionErrorR]RhRR`tupdatetget_varcet_keysR-tKeyErrorRat setdefaultR^tappendt ManifestErrortkeystreducetcopytrangetlenRjtremove( t compare_mtdupstm_dictstmtm_dictRtm_setst common_keystkRs((Rcs2/usr/lib/python2.7/vendor-packages/pkg/manifest.pytcomm s@    !'"  BcCstt|j|||S(sWhere difference() returns three lists, combined_difference() returns a single list of the concatenation of the three.(RWRRy(RJRltovtsv((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pytcombined_differenceRscCs|j|||}d}xht|D]Z\}}|sQ|dt|7}q(|sn|dt|7}q(|d||f7}q(W|S(sOutput expects that self is newer than other. Use of sets requires that we convert the action objects into some marshalled form, otherwise set member identities are derived from the object pointers, rather than the contents.RMs+ %s s- %s s %s -> %s (RyRtstr(RJtotherRRRStouttsrctdest((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pythumanized_differencesWsccscd}|j|}xD|D]<}x3||D]'}td||}t|dVq0WqWdS(sGenerate contents of dircache file containing all dirctories referenced explicitly or implicitly from self.actions. Include variants as values; collapse variants where possible.css&xt|jD] }|VqWdS(N(R tdirectory_references(Rctd((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pytgen_referencesnstpaths N(t_actions_to_dictRR(RJRtdirsRRXRc((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyt_gen_dirs_to_stris   ccsd}|j|}x|jD]\}}i|dd6|dd6|dd6}x\|D]T}d|d d jd |jDd jd |jDf}|Vq_Wq%Wd S(sGenerate contents of mediatorcache file containing all mediators referenced explicitly or implicitly from self.actions. Include variants as values; collapse variants where possible.cssu|jdks|jdkrqd|jkrq|jjd|jjd|jjd|jjdfVndS(NRZR[R\smediator-prioritysmediator-versionsmediator-implementation(R^RR_(Rc((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyR}s ismediator-priorityismediator-versionismediator-implementations%set name=pkg.mediator value=%s %s %s it css(|]}|drdj|VqdS(it=N(RT(Rtt((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pys scss|]}dj|VqdS(RN(RT(RR((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pys sN(RRRT(RJRt mediatorst mediationt mvariantstvaluestmvariantRc((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyt_gen_mediators_to_strxs"    c #s_d|k}d|k}d|ko-d|k}t|||fsIdSttx;|jD]0}|d dkr_t|j||sicss%|]}td|DVqdS(css|]}|dVqdS(iN((Rtvpair((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pys sN(R-(Rtvarkey((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pys sc3s+|]!}tfd|DVqdS(c3s/|]%tfdDVqdS(c3s|]}|fVqdS(N((Rtval(R^(s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pys sN(R-(R(tvariants(R^s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pys sN(R(Rtvcombo(R(s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pys sicss|]}|dVqdS(iN((Rtf((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pys @sRMspkg.facet.commoncss|]}d|VqdS(s%s%sN((RRX((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pys ]ss pkg.facet.%scss|]}|dVqdS(iN((RR((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pys escss|]}d|VqdS(s%s%sN((RRX((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pys ss pkg.sizes.%sscsz=%sssz=%sspkg.sizes.common(( tanyRRhRDR]R^RR RtaddRR-RNRR*tget_pkg_otw_sizetget_action_chain_csizetget_sizeR=R tpoptitemstdifference_updateRt from_iterableRt intersectionR~thashlibtsha1RTt hexdigest(RJt emit_variantst emit_facetst emit_sizesR^tfacetstrefsRcRtafacetst avariantsR#RRt varcetkeystcfacetstfnamest merge_facetstvcombostpairtvfacetstvcfacetsRRPRXRRtrcsizetrsize((Rs2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyt_gen_attrs_to_strs                     "        "    csi}x|jD]j\}}tfd||D}xT|D]F}||krw|g||s(R8RRR(RJt referencesRRXRRtref((Rcs2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyRs     cCs|j|krt}n|tks9|jtks9ty|jd}WnJtk rg|jD]}tj|j^qg}|jds(RFR R}RR=R*tyield_matchingR Rhtgen_actions_by_typeRRRRRt _get_varcets( RJRFtpatternsRRtfoundtseenRcR((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyt gen_facetss> !    "    c cs|j|krt}n|tks9|jtks9ty|d}Wntk r`d}nX|dk r|tkrx7tjd||D] }||jj|gfVqWdSt }t t }x|j dd|D]}|j d}|dkrY|jd}t|dkr3|d d kr3dSxg|D]}t}|d |q:Wq|d dkrx1|jdD]}t}||j|qyWqqW|s|jd|d }nx,tjd||D]}|||fVqWdS( sA generator function that yields a list of tuples of the form (variant, [values]). Where 'variant' is the variant attribute name (e.g. 'variant.arch') and '[values]' is a list of the variant values supported by this package. Variants returned are those allowed by the specified (or current) excludes that also match at least one of the patterns provided.s pkg.variantsvariant.NRhRFR^RiiRMs variant.%si(RFR R}RR=R*RRDR_R RRhRRRRRRR( RJRFRRRXRRctanameR((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyt gen_variantss> !      " c#s`|jkrtntks9|jtks9ty|jd}WnJtk rg|jD]}tj|j^qg}|jdSssmediator-versions5.11Rsmediator-prioritysmediator-implementationN(RFR R}RARRR8RRRRhR_tversiontVersiont VersionErrorR(RJRFRRtretRtmed_verR((RFs2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyt gen_mediators=s2 ! :       ccs|j|krt}n|tks9|jtks9t|rNt|}n|j}x]|jD]R}xI|D]}||d|snPqnqnW|s|Vqat||ra|VqaqaWdS(s:Generate actions in manifest through ordered callable listRIN(RFR R}RRIR8R&(RJR"RFtpubRctc((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyR]js !  ccs|j|krt}n|tks9|jtks9t|rNt|}n|j}xi|jj|gD]R}xI|D]}||d|szPqzqzW|s|Vqmt||rm|VqmqmWdS(s]Generate actions in the manifest of type "type" through ordered callable listRIN(RFR R}RRIRCR_R&(RJtatypeR"RFRRcR((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyRs !  ccs@x9|D]1}x(|j|d|d|D] }|Vq)WqWdS(saGenerate actions in the manifest of types "atypes" through ordered callable list.R"RFN(R(RJtatypesR"RFRRc((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pytgen_actions_by_typess cCsd|j|d|DS(sgGenerate the value of the key attribute for each action of type "type" in the manifest.css$|]}|jj|jVqdS(N(RR_R`(RRc((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pys sRF(R(RJRRF((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pytgen_key_attribute_value_by_typesc Csd}g}g|jd|D] }|^q"}xtt|d||D]\}}t|}t} xbtt|dD]J} || j|| dr| j|| | j|| dqqW| rP|j || fqPqPW|S(sFind actions in the manifest which are duplicates (i.e., represent the same object) but which are not identical (i.e., have all the same attributes).cSs%|j|jj|jt|fS(s,Return a key on which actions can be sorted.(R^RR_R`Ra(Rc((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pytfunsRFRi( R]RRNRWRhRRRjRR( RJRFRtalldupsRctactsRtgtglistRRs((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyRzs %(  ccsd}d}g}t|tr0|j}nx|D]}|d7}|j}|jdry||dd!7}q7n|r||}d}n| s7|ddkrq7nytj|VWq7tjk r}|j|_||_ |j |q7Xq7W|rt j |ndS(NRMiis\it#( RGt basestringt splitlinestlstriptendswithR8Rt ActionErrorR@tlinenoRtapxtInvalidPackageErrors(RJtcontentt accumulateRterrorsRSte((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyt__content_to_actionss0       cCs@|dk s|dk st|o'| s1tg|_i|_i|_i|_g|_|ry(t|d}|j}WdQXWqt k r}t j |qXnt |t r|ri|j|d6|_n|j|}nx|D]}|j||qW||_t|jdks<tdS(sPopulate the manifest with actions. 'content' is an optional value containing either the text representation of the manifest or an iterable of action objects. 'excludes' is optional. If provided it must be a length two list with the variants to be excluded as the first element and the facets to be excluded as the second element. 'pathname' is an optional filename containing the location of the manifest content. 'signatures' is an optional boolean value that indicates whether a manifest signature should be generated. This is only possible when 'content' is a string or 'pathname' is provided. trbNssha-1i(R=R}R8RCRDRARBtopentreadtEnvironmentErrorRt_convert_errorRGRt hash_createREt_Manifest__content_to_actionst add_actionRFR(RJRRFtpathnameREtmfileRR!((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyt set_contents,       cCs|jd|jd|dS(sNRemove any actions from the manifest which should be excluded.RRFN(RR8(RJRF((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pytexclude_content scCs|j}|j}d|kr;d|kr;|d|dFs(tvarianttVariantCombinationTemplateRRD(RJ((RJs2/usr/lib/python2.7/vendor-packages/pkg/manifest.pytget_all_variantsCs  cCs%y ||SWntk r |SXdS(N(R(RJRtdefault((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyR_Ks  cCsR|j||j}|dkr(tS|dkr8tSttd|dS(s8Returns the boolean of the value of the attribute 'key'.ttruetfalses*Attribute value '%s' not 'true' or 'false'N(R_tlowerRR RR-(RJRRgR((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pytgetboolQs   cCs|j|krt}n|tks9|jtks9td}d}|j}d|krd|kr|tks|j|kr|d|dfSx=|jd|D])}||j7}|tj|7}qW|tkr||d<||dxsX#   GE  #  :5 -  #  <  ' @d  0    $ 5  tFactoredManifestcBs[eZdZdeddZdZdZdZdZ dZ dZ e dZ d Zd Zded Zeed Zeed ZedZdZedZdZdZdZdZdZdZe edZdedZedZedZ eedZ!dZ"e#dZ$RS(sThis class serves as a wrapper for the Manifest class for callers that need efficient access to package data on a per-action type basis. It achieves this by partitioning the manifest into multiple files (one per action type) and then storing an on-disk cache of the directories explictly and implicitly referenced by the manifest each tagged with the appropriate variants/facets.cCs>tj||||_||_t|jdks=tt|_t j j |j s|dkrst|n|jd||j|jr|jn|r|j|ndS|jd}t j j |s-t|_|j|jr |jn|r)||_|jndS|j|dS(sRaises KeyError exception if factored manifest is not present and contents are None; delays reading of manifest until required if cache file is present. 'fmri' is a PkgFmri object representing the identity of the package. 'cache_root' is the pathname of the directory where the manifest and cache files should be stored or loaded from. 'contents' is an optional string to use as the contents of the manifest if a cached copy does not already exist. 'excludes' is optional. If provided it must be a length two list with the variants to be excluded as the first element and the facets to be exclduded as the second element. 'pathname' is an optional string containing the pathname of a manifest. If not provided, it is assumed that the manifest is stored in a file named 'manifest' in the directory indicated by 'cache_root'. If provided, and contents is also provided, then 'contents' will be stored in 'pathname' if it does not already exist. iRNsmanifest.dircache(R>RLt_FactoredManifest__cache_roott_FactoredManifest__pathnameRRFR}R tloadedR1RtexistsRR=RRt_FactoredManifest__finiloadt_FactoredManifest__storebackt_FactoredManifest__unloadRt_FactoredManifest__cache_pathR t_FactoredManifest__load(RJR@t cache_roottcontentsRFRtmdpath((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyRLs4              cCstjj|j|S(N(R1RRTRz(RJR^((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyt __cache_pathscCs*|jd|jd|j|jdS(s8Load all manifest contents from on-disk copy of manifestRFRN(RRFRR~(RJ((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyt__loadscCs(g|_i|_i|_t|_dS(sfUnload manifest; used to reduce peak memory comsumption when downloading new manifestsN(R8RCRDR R|(RJ((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyt__unloads   cCs t|_dS(s_Finish loading.... this part of initialization is common to multiple code pathsN(RR|(RJ((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyt __finiload$scCsM|jsty"|j|j|jtSWntjk rHtSXdS(sx store the current action set; also create per-type caches. Return True if data was saved, False if notN( R|R}RaRt_FactoredManifest__storebytypeRRRPR (RJ((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyt __storeback)s c sjstjtjxUjjD]D\}}d|}y"tjdd|\}}Wn"t k r}t j |nXt j |d}zqyHx|D]}|jd|qW|dkr|jjnWn"t k r}t j |nXWd|jXy1t j|ttj|jd|Wq5t k rx}t j |q5Xq5Wfd } | d j| d jdS( s create manifest. files to accelerate partial parsing of manifests. Separate from __storeback code to allow upgrade to reuse existing on disk manifestss manifest.%s.RIRJRKs%s RhNs manifest.%scsyztjdd|d\}}tj|d}|j|WdQXtj|ttj|j |Wn"t k r}t j |nXdS(NRIRJRGRK( RURVR1RWt writelinesRYR RZR[RR RR (R^RR_R`RR(RJR](s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyt create_cachegssmanifest.dircachesmanifest.mediatorcache(R|R}RzR*RNRCRRURVR RR R1RWRXRRR6RYR RZR[RRR( RJRRR^R_R`RRRcR((RJR]s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyt __storebytype6s<        cCsyxztj|D]i}|jds.qny tjtjj||Wqtk r{}|jtj kr|q|qXqWytj |WnnXWn7tk r}|jtj krt j |qnXdS(sRemove all manifest cache files found in the given directory (excluding the manifest itself) and the cache_root if it is empty afterwards. s manifest.N( R1tlistdirRcRZRRRTR R+R,trmdirRR (RtcnameR((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyt clear_cachevs"c Cs |j|}tjj|ryot|dV}gd|DD]1}|j sr|j|jd|jrG|^qG|j|sRIN(RR1RR}RRFRRIRAR RR R8RRRzt ExceptionR|RR}(RJR^tmpathRRcR((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyt__load_cached_datas* %   cCs|jdtj||S(sq return a list of directories implicitly or explicitly referenced by this object smanifest.dircache(t#_FactoredManifest__load_cached_dataR>R(RJRF((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyRs c cs|jr;x+tj||d|d|D] }|Vq(WdS|jd}tjj|s|jsr|jnx+tj||d|d|D] }|VqWdS|tkr|j }n||j ks|j tkst ||j krdS|jd|}|rt |}nyt |dw}xm|D]e}tj|j}|rw|j|d|j rwq7n|s|Vq7t||r7|Vq7q7WWdQXWnHtk r}|jtjkr|j j|dStj|nXdS(s generate actions of the specified type; use already in-memory stuff if already loaded, otherwise use per-action types filesR"RFNsmanifest.dircaches manifest.%sRRI(R|R>RRR1RR}RR RFR}RBRRR8RRRRIR&R R+R,RRR ( RJRR"RFRcRRRSR((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyRsL       $   cCs=|j r$|j r$|jntj|d|d|S(sQA generator function that returns the supported facet attributes (strings) for this package based on the specified (or current) excludes that also match at least one of the patterns provided. Facets must be true or false so a list of possible facet values is not returned.RFR(R|t"_FactoredManifest__load_attributesRR>R(RJRFR((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyRs cCs=|j r$|j r$|jntj|d|d|S(sA generator function that yields a list of tuples of the form (variant, [values]). Where 'variant' is the variant attribute name (e.g. 'variant.arch') and '[values]' is a list of the variant values supported by this package. Variants returned are those allowed by the specified (or current) excludes that also match at least one of the patterns provided.RFR(R|RRR>R(RJRFR((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyRs cCs |jdtj|d|S(sA generator function that yields set actions expressing the set of possible mediations for this package. smanifest.mediatorcacheRF(RR>R(RJRF((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyRs c Cs|jd}tjj|s%tSt|db}xX|D]P}tj|j}|j s~|j |j d|j r>|j |q>q>WWdQXt S(saLoad attributes dictionary from cached set actions; this speeds up pkg info a lots manifest.setRRIN(RR1RR}R RR8RRRFRRIRR(RJRRRSRc((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyt__load_attributes&s   cCs7|j r$|j r$|jntj|d|S(sReturns an integer tuple of the form (size, csize), where 'size' represents the total uncompressed size, in bytes, of the Manifest's data payload, and 'csize' represents the compressed version of that. 'excludes' is a list of a list of variants and facets which should be allowed when calculating the total.RF(R|RRR>R(RJRF((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyR7s cCs4|j r$|j r$|jntj||S(N(R|RRR>Rt(RJR((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyRtCs cCsds tdS(s-No assignments to factored manifests allowed.sFactoredManifests are not dictsN(R}(RJRR((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyRvHscCs4|j r$|j r$|jntj||S(N(R|RRR>Rw(RJR((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyRwLs cCs%y ||SWntk r |SXdS(N(R(RJRRg((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyR_Qs  cCs4|j r$|j r$|jntj||S(N(R|RRR>Rb(RJR^((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyRbWs cCs1|j r$|j r$|jntj|S(N(R|RRR>Rf(RJ((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyRf\s cCstj||d|S(NR8(R>R@(t cache_pathRFR8((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyR@ascCs/|js|jntj|d|d|S(NR"RF(R|RR>R](RJR"RF((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyR]fs  cCs#|js|jntj|S(N(R|RR>RQ(RJRF((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyRQls  cCs)|js|jntj|d|S(NRF(R|RR>Rz(RJRF((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyRzqs  cCs2|js|jntj||d|d|S(NRmRn(R|RR>Ry(RJRlRmRn((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyRyvs   cCs0|js|jntt|j|dS(s$Store the manifest contents to disk.N(R|RtsuperRyRa(RJR\((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyRa~s  cCs&|jr|jStjj|jdS(s:The absolute pathname of the file containing the manifest.tmanifest(R{R1RRTRz(RJ((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyRs N(%R,R6RxR=R RLRRRR~RRR<RRRRRRRRRRtRvRwR_RbRfR R@R]RQRzRyRatpropertyR(((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyRysB @     @ ) B             RgcBsGeZdZdZeedZedZdZdZ RS(sSpecial class for pkgplan's need for a empty manifest; the regular null manifest doesn't support get_directories and making the factored manifest code handle this case is too ugly...cCstj|dS(N(R>RL(RJ((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyRLscCs5tggg|jd|D]}|df^qS(sReturn three lists of action pairs representing origin and destination actions. The first list contains the pairs representing additions, the second list contains the pairs representing updates, and the third list contains the pairs representing removals. All three lists are in the order in which they should be executed.RFN(R'R]R=(RJRlRmRnRc((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyRys  cCsgS(N((RF((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyRscOsdS(N((RJR4tkwargs((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyRscOstddS(Ns3Cannot call set_content on an EmptyFactoredManifest(t RuntimeError(RJR4R((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyRs( R,R6RxRLR RyR<RRR(((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyRgs   RcBs#eZdZedZdZRS(s9Simple Exception class to handle manifest specific errorscCs ||_dS(N(t_ManifestError__duplicates(RJRz((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyRLscCs8g}x"|jD]}|jd|qWdj|S(Ns%s %s s (RRRT(RJRR((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyRQs(R,R6RxR RLRQ(((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pyRs (7t collectionsRRR+RRR1RRUt itertoolsRRRRRtoperatorRt pkg.actionsR8tpkg.client.api_errorstclientt api_errorsRt pkg.facetRntpkg.fmriR@tpkg.miscR*t pkg.portableRZt pkg.variantRdt pkg.versionRRR R R R tpkg.actions.attributeR tpkg.actions.directoryRRR&R'tobjectR>tnullRyRgtNullFactoredManifestRR(((s2/usr/lib/python2.7/vendor-packages/pkg/manifest.pytsF      (( &V &