~Z>dd k?l@Z@lAZAdd kBlCZCd ZDeiEd d ZFdZGdZHdZIdZJdZKdZLdZMdZNdZOdZPdZQdZRdZSde:e6iTiUeiVe6iTiWeiXfZYdZZei[dei\Z]ei[dZ^dd d!gZ_d"Z`ead#Zbddead$Zdd%eefd&YZfd'Zgd(Zhddd)Zid*Zjd+d,Zkdd-Zld.Zmdeadddd/Zndiddd2Zod3epfd4YZqd5Zrd6Zsd7ZteuZvd8ewfd9YZxd:epfd;YZyddd<Zzddd=Z{d>Z|d?Z}d@Z~dAZdBZddCZdDZdEepfdFYZdGefdHYZexZdjZe/e&Be$Be%BZe'e$Be0Be%Be1BZe&e$Be%BZdJdKZdLZddMZdNZdOZdPZdQZdRZedSZdTdUZdVZeeeeeedfZewefZeueeZeaZdddWZdddXZdYZdZZd[Zd\epfd]YZd^eefd_YZd`epfdaYZdbZdcZddZeeZdeZeaeaddfZdgZdhZdS(ks6 Misc utility functions used by the packaging system. iN(t defaultdict(t itemgetter(tS_IFMTtS_IMODEtS_IRGRPtS_IROTHtS_IRUSRtS_IRWXUtS_ISBLKtS_ISCHRtS_ISDIRtS_ISFIFOtS_ISLNKtS_ISREGtS_ISSOCKtS_IWUSRtS_IXGRPtS_IXOTH(tVERSION(tglobal_settings(t DebugValues(timg_type_namestIMG_NONE(t PkgGzipFiles/var/tmptdaysissignature-policysIhttps://defect.opensolaris.org/bz/enter_bug.cgi?product=pkg&component=clisIhttps://defect.opensolaris.org/bz/enter_bug.cgi?product=pkg&component=guicCstdhtd6S(sThis function returns the standard traceback message. A function is necessary since the _() call must be done at runtime after locale setup.s This is an internal error in pkg(5) version %(version)s. Please log a Service Request about this issue including the information above and this message.tversion(t_R(((s./usr/lib/python2.6/vendor-packages/pkg/misc.pytget_traceback_messageYscCsdS(s[Return a release note URL pointing to the correct release notes for this versions3https://support.oracle.com/rs?type=doc&id=2045311.1((((s./usr/lib/python2.6/vendor-packages/pkg/misc.pytget_release_notes_urlcscCstidti|S(s4convert seconds since epoch to %Y%m%dT%H%M%SZ formats%Y%m%dT%H%M%SZ(ttimetstrftimetgmtime(tt((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyttime_to_timestampkscCstiti|dS(s4convert %Y%m%dT%H%M%SZ format to seconds since epochs%Y%m%dT%H%M%SZ(tcalendarttimegmRtstrptime(tts((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyttimestamp_to_timepscCstii|dS(s2convert %Y%m%dT%H%M%SZ format to a datetime objects%Y%m%dT%H%M%SZ(tdatetimeR$(R%((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyttimestamp_to_datetimeuscCsrti|}ti||yti||i|iWn/tj o#}|i t i joqnnXdS(sBcopy a file, preserving attributes, ownership, etc. where possibleN( tostlstattshutiltcopy2tportabletchowntst_uidtst_gidtOSErrorterrnotEPERM(tsrc_pathtdst_pathtfste((s./usr/lib/python2.6/vendor-packages/pkg/misc.pytcopyfileysc Csd}ti|tti|}xetti|D]N}tii||}tii||}ti |}t |i o_t ||ti |t|i ti||i|iti||i|ifq;t|i obti||ti |t|i ti||i|iti||i|ifq;t|i otiti||q;t|i oRti|t|i ti||i|iti||i|ifq;t|i otiti}t tdoti!||i |i"nFy|i#||i$Wn'|i%j o} t&i'}q;nXti||i|iti||i|ifq;t(|i pt)|i oft tdoRti!||i |i"ti||i|iti||i|ifqq;t*|i djoq;t*|i djoq;dGt+t*|i GHq;Wti |t|i ti||i|iti||i|if|o|d|d|dndS( s)Rewrite of shutil.copytree() that can handle special files such as FIFOs, sockets, and device nodes. It re-creates all symlinks rather than copying the data behind them, and supports neither the 'symlinks' nor the 'ignore' keyword arguments of the shutil version. tmknodiisunknown file type:iiiN(,tNoneR)tmakedirst PKG_DIR_MODEtstattsortedtlistdirtpathtjoinR*R tst_modetcopytreetchmodRR.R/R0tutimetst_atimetst_mtimeR R+R8R tsymlinktreadlinkR tmkfifoRtsockettAF_UNIXthasattrR9tst_devtbindtcloseterrortsystexc_infoR RRtoct( tsrctdsttproblemtsrc_stattnamets_pathtd_pathtstsockt_e((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyRCsf        $cCstii|o4tii|tii|itii}nyti||WnKtj o?}ti |}|i t i jot |i ot||ti|qti||ti|t|i ti||i|iti||i|ifti|q|i t ijo*t |i otid||fq|i t ijo$t |i otid|qnXdS(s:Rewrite of shutil.move() that uses our copy of copytree().s.Cannot move a directory '%s' into itself '%s'.s$Destination path '%s' already existsN(R)R@tisdirRAtbasenametrstriptseptrenametEnvironmentErrorR*R2tEXDEVR RBRCR+trmtreeR8RDRR.R/R0RERFRGtunlinktEINVALtErrortENOTDIR(RURVR7R\((s./usr/lib/python2.6/vendor-packages/pkg/misc.pytmoves. ( # #  cCsXt}xH|D]@}|}x1|djo#|i|tii|}qWqW|S(sTgiven a set of directories, return expanded set that includes all componentst(tsettaddR)R@tdirname(tdirstouttdtp((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyt expanddirss   cCs#|ddjo|d}n|S(s0if 'u' donesn't have a trailing '/', append one.it/((tu((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyturl_affix_trailing_slashsspkg/%s (%s %s; %s %s; %%s; %%s)cCsC| p|idjo t}n |i}tt||f}|S(s4Return a string that can use to identify the client.N(ttypeR:Rt_client_versionR(timgt client_nametimgtypet useragent((s./usr/lib/python2.6/vendor-packages/pkg/misc.pytuser_agent_strs   s^(?:[a-zA-Z0-9\-]+[a-zA-Z0-9\-\.]* |(?:\d{1,3}\.){3}\d{3} |\[([a-fA-F0-9\.]*:){,7}[a-fA-F0-9\.]+\])$s.*[^a-zA-Z0-9\-\.:\[\]]+tfilethttpthttpscCs:|ptSti|otSti|otStS(s@Verify that the publisher prefix only contains valid characters.(tFalset_invalid_host_charstmatcht _hostname_retTrue(tprefix((s./usr/lib/python2.6/vendor-packages/pkg/misc.pytvalid_pub_prefixscCs|ptSti|}|dtjotS|ddjoHti|dddd}ti|}tii|ptSt Sti |dd}|o4|i d}t |djo|d}qn| pt i|otSti|ot StS(syVerify that the publisher URL contains only valid characters. If 'proxy' is set to True, some checks are relaxed.iRtallow_fragmentsiit@(Rturlparseturlsplitt _valid_prototurllibt url2pathnameR)R@tabspathRt splitporttsplittlenRRR(turltproxytoR@thostt host_parts((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyt valid_pub_url's*cCsJd}d}d}d}|p| o| otdn|id} | djotidnt|id} | djotid nt|id} |id | |@oCt|id} | d t|id} |i| n| |@o<x9to-|id} | p | d joPqqWn| |@o<x9to-|id} | p | d joPqbqbWn| |@o|idn|onC|o2g}x2|D]}|iti|qWn |}ti ti }xto|id}|djo_|i }|on7|o"x,|D]}|i |qbWn|i ||i |Pn|i|}|on7|o"x,|D]}|i |qWn|i ||i |qW|odS|o/g}x!|D]}|i|iqW|S|iS(sDecompress a gzipped input stream into an output stream. The argument 'gz' is an input stream of a gzipped file and 'outfile' is is an output stream. gunzip_from_stream() decompresses data from 'gz' and writes it to 'outfile', and returns the hexadecimal SHA sum of that data using the hash_func supplied. 'hash_funcs', if supplied, is a list of hash functions which we should use to compute the hash. If 'hash_funcs' is supplied, a list of hexadecimal digests computed using those functions is returned. The returned list is in the same order as 'hash_funcs'. If 'ignore_hash' is True, we do not compute a hash when decompressing the content and do not return any value. iiiis(no hash functions for gunzip_from_streamssNot a gzipped fileisUnknown compression methodiiti@iRlNi(t ValueErrortreadtzlibRQtordRtappendtdigestt HASH_ALGSt decompressobjt MAX_WBITStflushtupdatetwritet decompresst hexdigest(tgztoutfilet hash_funct hash_funcst ignore_hashtFHCRCtFEXTRAtFNAMEtFCOMMENTtmagictmethodtflagtxlenR\tshasumstftshasumtdcobjtbuftubuftshat hexdigests((s./usr/lib/python2.6/vendor-packages/pkg/misc.pytgunzip_from_streamNs             t PipeErrorcBseZdZddZRS(s Pipe exception. cCsti|||_dS(N(t Exceptiont__init__t_args(tselftargs((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyRs N(t__name__t __module__t__doc__R:R(((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyRsc Gsry3dig}|D]}|t|q~GHWn8tj o,}|itijo t|nnXdS(s Emit a message. t N(RAtstrtIOErrorR2tEPIPER(ttextt_[1]tlR7((s./usr/lib/python2.6/vendor-packages/pkg/misc.pytmsgs 3 c Gszy;tidig}|D]}|t|q~IJWn8tj o,}|itijo t|nnXdS(s Emit a message to sys.stderr. RN(RRtstderrRARRR2RR(RRRR7((s./usr/lib/python2.6/vendor-packages/pkg/misc.pytemsgs ; cCs|djo t}nyti||tiWnjtitfj oUydti}Wntj o d}nX|d|ti|dnXdS(sWraps locale.setlocale(), falling back to the C locale if the desired locale is broken or unavailable. The 'printer' parameter should be a function which takes a string and displays it. If 'None' (the default), setlocale() will print the message to stderr.s '%s.%s'Rls^Unable to set locale%s; locale package may be broken or not installed. Reverting to C locale.tCN(R:Rtlocalet setlocaletgetdefaultlocaleRiR(tcategorytloctprintertdl((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyRs   cCs|S(slReturn its argument; used to mark strings for localization when their use is delayed by the program.((tmessage((s./usr/lib/python2.6/vendor-packages/pkg/misc.pytN_ss%(num).2f %(unit)sc Cs$tdtddftdtddftdtddftd td dftd tddftdtddftdtdd fg}xo|D]g\}}}|tdjo||joqn|ht|t|d!dd6|d6|d6SWdS("s@Returns a human-formatted string representing the number of bytes in the largest unit possible. If provided, 'fmt' should be a string which can be formatted with a dictionary containing a float 'num' and strings 'unit' and 'shortunit'. The default format prints, for example, '3.23 MB' tBii tkBtkitMBtMitGBtGi(tTBtTi2tPBtPi<tEBtEiFtnumtunitt shortunitNiii@ll lli(Rtroundtfloat(tnbytestfmttunitstuomtshortuomtlimit((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyt bytes_to_strs  cCsI|i}|o|id|d}n|idd}d||S(sCalculate the depth of the current request path relative to our base uri. path_info always ends with a '/' -- so ignore it when calculating depth.s/%s/Ruis../(t path_infotreplacetcount(trequestturitpubtrpathtdepth((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyt get_rel_path s  cCsB|iid}|djo|iidd}nt|S(sTakes a file action and returns the over-the-wire size of a package as an integer. The OTW size is the compressed size, pkg.csize. If that value isn't available, it returns pkg.size. If pkg.size isn't available, return zero.s pkg.csizespkg.sizeiN(tattrstgetR:tint(tactiontsize((s./usr/lib/python2.6/vendor-packages/pkg/misc.pytget_pkg_otw_sizes cCsd}t}t|tot|d|}t}n|}|djoti|i}n|o |} nX|djp |djotp t dnh} x|D]} || | | iRL(R>iRM(R>iRN(R>iRO(RDiRP(RDiRQ(R=iRR(R=iRS(R7iRT(RAispr_size(RAiRV(RAiRW(R<iRX(R9iRY(R9iRZ(RGispr_start(RGiR\(RGiR](schar[]iR^(schar[]iPR_(sintiR`(sintiRa(R7iRb(R7iRc(schariRd(schar[]iRe(RBiRf(R@iRg(sintiRh(R?iRi(REiRj(RFiRk(sintiRlN(RRRt_ctype_formatst_timestruct_desct _psinfo_descR:Rnt iteritemst struct_nameRxRtRytcount1RYtcount2tfmt_charRt collectionst namedtupleRR4t staticmethodRsR|(((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyR1s       $ 0cCs)ti}|djodS|idS(s>Return the amount of virtual memory in bytes currently in use.iN(R1R|R:RU(R|((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyt __getvmusageZs  cCs<ti}|djodS|iit|iidS(snReturn the process start time expressed as a floating point number in seconds since the epoch, in UTC.ggeAN(R1R|R:R[RHRRI(R|((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyt_prstartbs  cCsd}y0t}|dj ot|dd}nWnEttfj o3}t|to|itijoq~nX|dj o d}nd}t|t S(sBReturn an out of memory message, for use in a MemoryError handler.Rs%(num).0f%(unit)ssMThere is not enough memory to complete the requested operation. At least %(vsz)s of virtual memory was in use by this command before it ran out of memory. You must add more memory (swap or physical) or allow the system to access more existing memory, or quit other programs that may be consuming memory, and try the operation again.sThere is not enough memory to complete the requested operation. You must add more memory (swap or physical) or allow the system to access more existing memory, or quit other programs that may be consuming memory, and try the operation again.N( R:RRt MemoryErrorRdRR2tENOMEMRtlocals(tvsztvmusaget__eRQ((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyt out_of_memoryjs     t ImmutableDictcBsqeZedZdZdZd dZdZd dZ dZ dZ dZ e d ZRS( cCsti||dS(N(tdictR(Rtdefault((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyRscCs|idS(N(t_ImmutableDict__oops(Rtitemtvalue((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyt __setitem__scCs|idS(N(R(RRR((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyt __delitem__scCs|idS(N(R(RRR((s./usr/lib/python2.6/vendor-packages/pkg/misc.pytpopscCs|idS(N(R(R((s./usr/lib/python2.6/vendor-packages/pkg/misc.pytpopitemscCs|idS(N(R(RRR((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyt setdefaultscCs|idS(N(R(RRr((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyRscCstS(N(R(R((s./usr/lib/python2.6/vendor-packages/pkg/misc.pytcopyscCs|idS(N(R(R((s./usr/lib/python2.6/vendor-packages/pkg/misc.pytclearscCs tddS(Ns Item assignment to ImmutableDict(t TypeError(((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyt__oopssN(RRtEmptyIRRRR:RRRRRRRR(((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyRs         t DictPropertyc BsWeZdefdYZddddddddddddd ZddZRS(t__InternalProxycBszeZdZdZdZdZdZdZdZd dZ d dZ d Z d Z d ZRS( c Csp||_||_||_||_||_||_||_||_| |_| |_ | |_ | |_ dS(N( t_InternalProxy__objt_InternalProxy__fgett_InternalProxy__fsett_InternalProxy__fdelt_InternalProxy__iteritemst_InternalProxy__keyst_InternalProxy__valuest_InternalProxy__itert_InternalProxy__fgetdefaultt_InternalProxy__fsetdefaultt_InternalProxy__updatet_InternalProxy__pop( RtobjtfgettfsettfdelRtkeystvaluestiteratort fgetdefaultt fsetdefaultRR((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyRs           cCs0|idjo tdn|i|i|S(Nsunreadable attribute(RR:tAttributeErrorR(Rtkey((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyt __getitem__s cCs7|idjo tdn|i|i||dS(Nscan't set attribute(RR:RR(RRR((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyRs cCs4|idjo tdn|i|i|dS(Nscan't delete attribute(RR:RR(RR((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyRs cCs-|idjo tdn|i|iS(Nscan't iterate over items(RR:RR(R((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyRs cCs-|idjo tdn|i|iS(Nscan't iterate over keys(RR:RR(R((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyRs cCs-|idjo tdn|i|iS(Nscan't iterate over values(RR:RR(R((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyRs cCs3|idjo tdn|i|i||S(Ns can't use get(RR:RR(RRR((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyRs cCs3|idjo tdn|i|i||S(Nscan't use setdefault(RR:RR(RRR((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyRs cCs0|idjo tdn|i|i|S(Nscan't use update(RR:RR(RRr((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyRs cCs3|idjo tdn|i|i||S(Ns can't use pop(RR:RR(RRrR((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyRs cCs-|idjo tdn|i|iS(Ns can't iterate(RR:RR(R((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyt__iter__s N(RRRRRRRRRR:RRRRR(((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyRs           c Csp||_||_||_||_||_||_||_||_| |_| |_ | |_ | |_ dS(N( t_DictProperty__fgett_DictProperty__fsett_DictProperty__fdelt_DictProperty__iteritemsRt_DictProperty__keyst_DictProperty__valuest_DictProperty__itert_DictProperty__fgetdefaultt_DictProperty__fsetdefaultt_DictProperty__updatet_DictProperty__pop( RRRRRRRRtdocRRRR((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyRs           c Csa|djo|S|i||i|i|i|i|i|i|i|i |i |i |i S(N( R:t_DictProperty__InternalProxyRRRRRRRRRRR(RRtobjtype((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyt__get__s  N(RRtobjectRR:RR(((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyRs I c Csy)t|d}|i}|iWntj o}|itijoti|d|d|n|itijoti |i n|iti joti |i nnXyt it i|SWn3t ij o$}ti|d|d|nXdS(sBTake the file given in path, open it, and use it to create an X509 certificate object. 'uri' is an optional value indicating the uri associated with or that requires the certificate for access. 'pub' is an optional string value containing the name (prefix) of a related publisher.RRt publisherN(RRRPRdR2tENOENTt api_errorstNoSuchCertificatetEACCEStPermissionsExceptiontfilenametEROFStReadOnlyFileSystemExceptiontosctload_certificatet FILETYPE_PEMRitInvalidCertificate(R@RRtcftcertdataR7((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyt build_certs$   c Cs4t|d|d|}|ioti|d|d|ntii}|i}ti|d}tii t i |}||joti |d|d|n|i }ti|d}tii t i |} | |} | tjo(ti|d|d|d| in|S(sjValidates the indicated certificate and returns a pyOpenSSL object representing it if it is valid.RRRs %Y%m%d%H%M%SZR(Rt has_expiredRtExpiredCertificateR'tutcnowt get_notBeforeRR$tutcfromtimestampR"R#tNotYetValidCertificatet get_notAftert MIN_WARN_DAYStExpiringCertificateR( tssl_certRRtcerttnowtnbR tnbdttnatnadttdiff((s./usr/lib/python2.6/vendor-packages/pkg/misc.pytvalidate_ssl_cert9s*          t0123456789abcdefcCs[d}xN|D]F}t|}t|d}|d}t|d}|||7}q W|S(sDConverts a string of bytes to a hexadecimal representation. Rli(Rt char_list(R\tresRstatb((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyt binary_to_hex_s  cCscd}xVtdt|dD]<}|tti||dti||d7}qW|S(sFConverts a string of hex digits to the binary representation. Rliiii(RRtchrRtfind(R\RR4((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyt hex_to_binaryls  cCs?dddg}x)|D]!}ti|}|odSqWtS(sExamine the environment. If the environment has set TMPDIR, TEMP, or TMP, return None. This tells tempfile to use the environment settings when creating temporary files/directories. Otherwise, return a path that the caller should pass to tempfile instead.tTMPDIRtTEMPtTMPN(R)tgetenvR:tDEFAULT_TEMP_PATH(ttmp_envstevtenv_val((s./usr/lib/python2.6/vendor-packages/pkg/misc.pytconfig_temp_rootvs  cCs?dddg}x)|D]!}ti|}|o|SqWtS(sReturn the directory path where the temporary directories or files should be created. If the environment has set TMPDIR or TEMP or TMP then return the corresponding value else return the default value.RRR(R)RR(ttemp_envtenvR((s./usr/lib/python2.6/vendor-packages/pkg/misc.pytget_temp_root_paths cCs7|iddjo|id o|ptii|}n9tii|p%tiitii||}nti ddt i |dddf}nti|ddd\}}}}}}|i }|djo+|idod|i d}qnti ||||||fS( sParse the repository location provided and attempt to transform it into a valid repository URI. 'cwd' is the working directory to use to turn paths into an absolute path. If not provided, the current working directory is used. s://isfile:/RRlRiRu(Rt startswithR)R@RtisabstnormpathRARt urlunparseRt pathname2urltlowertlstrip(RtcwdtschemetnetlocR@tparamstquerytfragment((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyt parse_uris'% "*  cCsyti|tWntj o}|i|jo.|itijptii|iodS|iti jot i |iq|iti jot i |iq|itijp|i|joqnXdS(sCreate a directory at the specified location if it does not already exist (including any parent directories) re-raising any unexpected exceptions as ApiExceptions. N(R)R;R<RdRR2tEEXISTR@texistsRRRRR(tpathnameR7((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyR;s##t DummyLockcBsDeZdZdZddZdZdZedZRS(sThis has the same external interface as threading.Lock, but performs no locking. This is a placeholder object for situations where we want to be able to do locking, but don't always need a lock object present. The object has a held value, that is used for _is_owned. This is informational and doesn't actually provide mutual exclusion in any way whatsoever.cCs t|_dS(N(Rtheld(R((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyRsicCs t|_tS(N(RR(Rtblocking((s./usr/lib/python2.6/vendor-packages/pkg/misc.pytacquires cCs t|_dS(N(RR(R((s./usr/lib/python2.6/vendor-packages/pkg/misc.pytreleases cCs|iS(N(R(R((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyt _is_ownedscCs|iS(N(R(R((s./usr/lib/python2.6/vendor-packages/pkg/misc.pytlockeds( RRRRRRRtpropertyR(((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyRs     t SingletoncBs eZdZdZdZRS(sqSet __metaclass__ to Singleton to create a singleton. See http://en.wikipedia.org/wiki/Singleton_pattern cCs)tt|i|||d|_dS(N(tsuperRRR:tinstance(tmcsRYtbasest dictionary((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyRscOs9|idjo"tt|i|||_n|iS(N(RR:RRt__call__(RRtkw((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyR"s(RRRRR"(((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyRs it.cCsP|o3|o,|djo|ddjo|idStii|d|S(sbVersion of relpath to workaround python bug: http://bugs.python.org/issue5117 Ruitstart(R R)R@trelpath(R@R%((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyR&s,cCsxti|D]\}}}x6|D].}tii||}ti|||q&Wx6|D].}tii||}ti|||q_WqWdS(s?Change the ownership of all files under directory d to uid:gid.N(R)twalkR@RAR-R.(Rrtuidtgidtdirpathtdirnamest filenamesRYR@((s./usr/lib/python2.6/vendor-packages/pkg/misc.pytrecursive_chown_dir sc sg}d}t}xnD]f}t|tjoqnt|djo|\} } n't|djo|\} } } n| |jpt|| \} } | p| pt| djoX| d jpt| tjo|id| n|id| | |d| tiD]0\}}|id|id||fqvW|S(sWhen running a pkg(1) command from within a packaging module, try to use the same pkg(1) path as our current invocation. If we're running pkg(1) from some other command (like the gui updater) then assume that pkg(1) is in the default path.tpkgs-Ds%s=%s( RQR)R@R`R=R1RRR(tpkg_binRPtpkg_cmdRRx((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyt api_pkgcmds        cCsMtid}| o!dtijotid}n|p d}n|S(s\Return path to the current live root image, i.e. the image that we are running from.tsimulate_live_roott PKG_LIVE_ROOTRu(RROR)RN(t live_root((s./usr/lib/python2.6/vendor-packages/pkg/misc.pytliveroots  cCs<y!ti|}|i|iSWntj odSXdS(spFind out how much space is available at the specified path if it exists; return -1 if path doesn't existiN(R)tstatvfstf_frsizetf_bavailR1(R@R((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyt spaceavails cCsLy!tdti|DSWn$tj o}ti|nXdS(sBReturn the size (in bytes) of a directory and all of its contents.cssNxG|]@\}}}x.|D]&}tiitii||VqWqWdS(N(R)R@tgetsizeRA(t.0RrtdnamestfnamesR((s./usr/lib/python2.6/vendor-packages/pkg/misc.pys s N(tsumR)R'RdRt_convert_error(R@R7((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyt get_dir_sizes csQfd}d}ddd} fdfd} djo|} |} n d joHtfd D} d id t| D} } nd jp djohtd6}djod|ds (s\Rs s RnRoRpRqRrRsRtRuRvRw(R(tvaltnvalR2(t out_format(s./usr/lib/python2.6/vendor-packages/pkg/misc.pyt quote_value#s csE|d}t}t|ttttfo t}nJ|djod|ddZs s cssx|] }dVqWdS(s%sN((R_R1((s./usr/lib/python2.6/vendor-packages/pkg/misc.pys ]s tjsonsjson-formattedt sort_keysitindentcst|to|St|ttttfo&g}|D]}||q<~St|to2x*|iD]\}}|||ts s Rlc3s:x3|],\}}|jo||fVqqWdS(N((R_RRx(R(s./usr/lib/python2.6/vendor-packages/pkg/misc.pys s  ( RbRAtxrangeRRtdumpsRtmapR>tfilterRR/R(RgRt field_valuesRztdef_fmtt omit_headersR~RiRkRORRt filter_funct num_fieldsRRtoutputthdrsR(( RgRzRRhR{RmRARR~s./usr/lib/python2.6/vendor-packages/pkg/misc.pyt get_listingsV,     #       3     icCsNy|i|Wn6tj on%tj o}ti|nXdS(sTruncate the specified file.N(ttruncateRR1RRc(RRR7((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyt truncate_files cCsytiiWn6tj on%tj o}ti|nXytiiWn6tj on%tj o}ti|nXdS(sflush stdout and stderrN(RRtstdoutRRR1RRcR(R7((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyt flush_outputscCs/|djo1to*tidI|IJtidI|IJn|djodS|djo t}n|djo(t}dg}h}|||g}nFt}|\}}}|p |}n t||B}|||g}t|tjpt t|t jpt t|t jo$t |djo|ddjpt t|tjpt t|t jot |djpt d} t |to |} n t|} t|dt|} t| | pt d| || |ft | t pt d |x2tD]*} t| | o| ||||Sq4W| t tifjoh} t |djo!| i|| || ||S|id\}}t |tot |djpt xt|iD]f\}}d ||f}t|||d |}d ||f}t|||d |}|| |): ( , ) } when we finish the object cache we update it so that it contains just encoded objects hashed by their assigned object id (obj_id). so the hash contains: { str(): } then we merge the state data and object cache into a single dictionary and return that. it json_statet json_objectstplandesc_validatesjson_encode finished name: sjson_encode finished data: (t itervaluesRRt json_validatet json_debugRRR(RYR tfinishtje_statet obj_cachet obj_cache2tobj_idt obj_state((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyt je_returns   t __metaclass__s-unexpected %s for %s, expected: %s, value: %ssunexpected unicode string: %ss %s[%s].key()Rs%s[%s].value()s%d >= %dt fillvalues%s[%i]tgetstatesno json encoder for: %ss"json encoder returned none for: %sN(R:RRRRR|RRRxRRRRoRRtgetattrt issubclasstunicodetjson_types_immediatesRRRtitemsRt json_encodeR/Rmtextendt itertoolst izip_longestRtid(RYR Rtt commonizeRRRRt commonize_oldRt desc_typet data_typeR Rvtdesc_ktdesc_vRRxtname2tk2tv2R4tdata2tdesc2tencoder((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyRs      >- /                cCs |djo1to*tidI|IJtidI|IJn|djo|S|djo t}n|djo;t}|p h}n|d}|d}||g}n~t}|\}}| o|o|d}|d}nt}|p |}nt||B}t}|o||g}nt|tjpt dt|t|t jpt t|tjpt t|t jot |djpt d} t |to |} n t|} x5tD]-} t| | o| |||||SqWt |t o|i} | it |djo$| i|| || |||S|id\} }t | tot |d jpt xt|iD]f\}}d || f}t||| d |}d || f}t|||d |}|| |= %dRs%s[%i]t fromstatesno json decoder for: %sRN(R:RRRRR|RRRxRRRRoRRRRRRRRRt json_decodeR/RmRRRRR(RYR RtRRRRRtje_state_changedRRR RvRRRRxRRRtrvtypeR4RRtdecoderR((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyRs           '-                       cCst|tp#tdt||t|ft|tjotxq|D]e}t|tjptd|d||f}t||d||f}t|||qMWnt|tjoBx?t t |D]'}d||f}t|||qWndS(s*Validate that a named piece of data can be represented in json and that the data can be passed directly to json.dump(). If the data can't be represented as json we'll trigger an assert. 'name' is the name of the data to validate 'data' is the data to validate 'recurse' is an optional integer that controls recursion. if it's a negative number (the default) we recursively check any nested lists or dictionaries. if it's a positive integer than we only recurse to the specified depth.s*invalid json type "%s" for "%s", value: %ss(integer dictionary keys detected for: %ss %s[%s].key()s%s[%s].value()s%s[%i]N( Rt json_typesRRxRRRRRoRR(RYR Rtnew_nameR4((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyRs"  c sfd}ttjp*td|ttf|ttjottjp>td|ttttf|x@D]4}d||f}t|||qWnttjottjp*td|ttf|xLttD]4}d||f}t|||qqWndS(scCompare two json encoded objects to make sure they are identical, assert() if they are not.csAd}d|d|d|d|S(sdump debug info for json_diffcSsti|dtddS(s dbg helperRRi(RRR(R\((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyRrss --- d0 s +++ d1 s --- alld0 s +++ alld1 ((Rr(talld0talld1td0td1(s./usr/lib/python2.6/vendor-packages/pkg/misc.pytdbgs s7Json data types differ for "%s": type 1: %s type 2: %s sLJson dictionary keys differ for "%s": dict 1 missing: %s dict 2 missing: %s s%s[%s]sGJson list lengths differ for "%s": list 1 length: %s list 2 length: %s s%s[%i]N(RxRRRmt json_diffRoRR( RYRRRRRRRR4((RRRRs./usr/lib/python2.6/vendor-packages/pkg/misc.pyRs*$5&!cCs}h}xp|iD]b\}}t|tjo|id}nt|tjo|id}n||||i} | d jo!|} | d jo d} qqn5| d jo | } n| d jo | } nd} | i | qEW| o9g}| D]$}t |djo ||qq~p|o1| p|d jp || jo| }| Vq#q#Wd S(sProduces a list of n tuples (where n is the length of attrs) containing the relevant information about the actions. The "actionlist" parameter is a list of tuples which contain the fmri of the package that's the source of the action, the action, and the publisher the action's package came from. If the actionlist was generated by searching, the last two pieces, "match" and "match_type" contain information about why this action was selected. The "attrs" parameter is a list of the attributes of the action that should be displayed. The "show_all" parameter determines whether an action that lacks one or more of the desired attributes will be displayed or not. The "remove_consec_dup_lines" parameter determines whether consecutive duplicate lines should be removed from the results. The "last_res" parameter is a seed to compare the first result against for duplicate removal. s action.names action.keys action.rawthashs action.hashRlspkg.namespkg.fmris pkg.shortfmris pkg.publishers search.matchssearch.match_typeN(shashs action.hash( RRRYtkey_attrRtget_nametget_fmritget_short_fmrit get_publisherR:RR(t actionlistRtshow_alltremove_consec_dup_linestlast_rest last_linetpfmriRRRt match_typetlineRRRR((s./usr/lib/python2.6/vendor-packages/pkg/misc.pytlist_actions_by_attrs' sP                 G c Cst|}t|}g}t|dD]2}|g}t|dD] }|dqK~q-~}d} d} d} x*t|dD]}| |||dR(Rt known_wordst candidatestknowntdistanceRR2((s./usr/lib/python2.6/vendor-packages/pkg/misc.pytsuggest_known_words s(ii(RtOpenSSL.cryptotcryptoRR R"RR'R2R R6RRR)tplatformRRR+R+t simplejsonRRKRpRRRRRRRRRtoperatorRR=RRRRRRRR R R R R RRRRtpkg.client.api_errorstclientRt pkg.portableR-t pkg.digestRRRRt pkg.clientRtpkg.client.debugvaluesRtpkg.client.imagetypesRRt pkg.pkggzipRRt timedeltaRtSIGNATURE_POLICYt BUG_URI_CLIt BUG_URI_GUIRRR!R&R(R8RCRkRtRwtutiltget_canonical_os_nametmachinetget_os_releaseRRyR~RtXRRRRRRR:RRRRRRRRRRRR0RR1RRRR/RRRRRRRRRRRRR;RRxRt EmptyDicttPKG_FILE_BUFSIZt PKG_FILE_MODER<tPKG_RO_FILE_MODER&R-RIRQRURYR]RdRRRRR:RRR5RRRotjson_types_collectionsRRRRRRRRRRRRR'R)R-R<RDRI(((s./usr/lib/python2.6/vendor-packages/pkg/misc.pyts                         j     H    ' e    PH   ! %g$   !        % % Sd 3 %  B