,9Mc@s\dZdZddkZddkZddkZddkZddkZddkZddkZddk l Z ddk l Z ddk l Z ei Z ei Z eiZeiZeiZhdZeiZedjoeidjo d Zneoed Zn eiZd Zd Zd ZdZdZde fdYZeidZdZ ddpdYZ!ddghdZ"dZ#dddghdZ$yde%fdYZ&Wne'j odZ(dZ)dZ*dZ+e,ed o d!Z-n d"Z-d#Z.dd$Z/dd%Z0e,ed oei1Z1d&Z2ne%Z2d'Z3d(Z4n"Xe5e fZ6e7e fZ8e7e9e fZ:e%e;e fZ<e%e;fZ=e>e6d)Z(e>e8d*Z)e>e:d+Z*e>e9d,Z+e>e<d-Z-e>e<e:d.Z.e>e<e:d/Z?e>e<e:e?d0Z/e>e<e:e?d1Z0e>e%e e=d2Z2e>ei@e%e2e=e:e d3Z4e4eAd4Z3hZBZCd5ZDeDeCeiEYZ\e\ZWq XnXeKo1eMi]Z]eMi^Z^eMi_Z_eMi`Z`d?Zanyy ebZcWn>edj o2d@eefdAYZbddkfZfebef_bnX[cdZ]dZ^dZ_dZ`dBZadCZOeidjoddgdDZgn9eihdEjoddgdFZgnddgdGZgeiid<ddHZjeiid<ddIZkeidJjo dKZln dLZle!ZmdMZndNe fdOYZodPe fdQYZpdRepfdSYZqeidJjo dTZrn dUZresdVZtdWZuddXZvdYZwdZdrd[YZxd\e fd]YZyd^dsd_YZzd`Z{ddaZ|dbZ}esZ~dcZdddeZyddkZWneXj on1Xe,edfoeZ~dgZdddhZndiZyeWn#edj oddjklZnXdkZdldtdmYZdnefdoYZ[dS(us0SCons.Util Various utility functions go here. s7src/engine/SCons/Util.py 4629 2010/01/17 22:23:21 sconsiN(tUserDict(tUserList(t UserStringcCs.x't||D]\}}|||s cCs*x#|D]}||jodSqqWdS(s<Check whether sequence str contains ANY of the items in set.ii((tstrtsettc((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyt containsAnyFs  cCs*x#|D]}||jodSqqWdS(s<Check whether sequence str contains ALL of the items in set.ii((RRR((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyt containsAllLs  cCs*x#|D]}||jodSqqWdS(s6Check whether sequence str contains ONLY items in set.ii((RRR((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyt containsOnlyRs  cCsjt|ti}ti|d}||jo+t||d o|| ||fSn |dfSdS(s&Same as os.path.splitext() but faster.t.s 0123456789.tN(RtosRR R R(RRtdot((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pytsplitextXs "cCs:tii|\}}|oti||}n|S(s Make the drive letter (if any) upper case. This is useful because Windows is inconsitent on the case of the drive letter, which can cause inconsistencies when calculating command signatures. (RRt splitdriveR tupper(Rtdrivetrest((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pytupdrivebstNodeListcBs;eZdZdZdZdZdZdZRS(siThis class is almost exactly like a regular list of Nodes (actually it can hold any object), with one important difference. If you try to get an attribute from this list, it will return that attribute from every item in the list. For example: >>> someList = NodeList([ ' foo ', ' bar ' ]) >>> someList.strip() [ 'foo', 'bar' ] cCst|idjS(Ni(tlentdata(tself((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyt __nonzero__xscCstitt|iS(N(R tjointmapRR%(R&((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyt__str__{scCs t|iS(N(titerR%(R&((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyt__iter__~scOs(t||d|i}|i|S(NcSst|||S((tapply(txtargstkwargs((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyts(R)R%t __class__(R&R/R0R((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyt__call__s cCs%t|d|i}|i|S(NcSs t||S((tgetattr(R.tn((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyR1s(R)R%R2(R&tnameR((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyt __getattr__s(t__name__t __module__t__doc__R'R*R,R3R7(((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyR#ns      s!^\$([_a-zA-Z]\w*|{[_a-zA-Z]\w*})$cCs[tit|}|o7|id}|ddjo|dd!SqW|SndSdS(sGiven a string, first determine if it looks like a reference to a single environment variable, like "$FOO" or "${FOO}". If so, return that variable with no decorations ("FOO"). If not, return None.iit{iN(t _get_env_vartmatcht to_StringtgrouptNone(tvarstrtmotvar((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pytget_environment_varst DisplayEnginecBs2eZdZddZddZdZRS(cCs|i|_dS(N(tprint_itR3(R&((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyt__init__sicCsC|o|d}nytii|Wntj onXdS(Ns (tsyststdouttwritetIOError(R&ttexttappend_newline((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyRFs cCsdS(N((R&RLRM((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyt dont_printscCs'|o|i|_n |i|_dS(N(RFR3RN(R&tmode((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pytset_modes(R8R9RGRFRNRP(((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyREs   ic Cst|}||}d}x1|d D]%}|o|d}q)|d}q)W|i|o|d|dSn|d|d}|pti|}nd ||s   cCs8y |i}Wntj ot|Sn X|SdS(N(t for_signaturetAttributeErrortto_String_for_subst(R|tf((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pytto_String_for_signatures  cCs1t|otitt|Snt|S(N(RR R(R)RR>(R((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyRs cCs |||S(N((R|R{t DictTypes((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyR~scCs |||S(N((R|R{t ListTypes((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyRscCs |||S(N((R|R{t SequenceTypes((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyRscCs |||S(N((R|R{ttuple((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyRscCs |||S(N((R|R{t StringTypes((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyRscCs|||p||| S(N((R|R{RR((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyRscCsTxM|D]E}|||p||| o|i|qt||qWdS(N(RTt do_flatten(RRR{RRR((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyRs !cCs|||p||| o |gSng}xM|D]E}|||p||| o|i|q9|||q9W|S(sFlatten a sequence to a non-nested list. Flatten() converts either a single scalar or a nested sequence to a non-nested list. Note that flatten() considers strings to be scalars instead of sequences like Python would. (RT(R|R{RRRRR((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyRs! !cCsZg}xM|D]E}|||p||| o|i|q |||q W|S(sFlatten a sequence to a non-nested list. Same as flatten(), but it does not handle the single scalar case. This is slightly more efficient when one knows that the sequence to flatten can not be a scalar. (RT(RR{RRRRR((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyRs!cCsA|||o|Sn&|||o |iSn ||SdS(N(R%(RR{RRtBaseStringTypes((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyR>s  c Cs|||o|Snn|||o8g}x!|D]} |it| q5W||Sn&|||o |iSn ||SdS(N(RTRR%( RR{R(RR>RRRtlte((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyR!s cCs8y |i}Wn|j o||Sn X|SdS(N(R(R|RRR((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyR5s  cCs7h}x*|iD]\}}t|||}ti|ti|t | jodg}PqqWt | ot | o |g}nx|D]}ti i ||}xi|D]a}||}ti i|o>y|i|Wqatj oti i|SqaXqaqaqaWq?WdS(NtPATHtPATHEXTs.COM;.EXE;.BAT;.CMDR(R@RtenvirontKeyErrorRR tsplittpathseptlowerR$RRRR(tisfiletindext ValueErrortnormpath(tfileRtpathexttrejecttexttdirRtfext((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pytWhereIssD     *    tos2c Cs|djo/ytid}Wq<tj o dSq<Xnt|oti|ti}n|djoddg}nxF|D]>}ti|ti|t | jodg}PqqWt | ot | o |g}nx|D]}ti i ||}xi|D]a}||}ti i|o>y|i|Wqtj oti i|SqXqqqWqWdS(NRs.exes.cmdR(R@RRRRR RRRR$RRRR(RRRR(RRRRRRRR((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyRs:    *    c Cs]ddk}|djo/ytid}WqHtj o dSqHXnt|oti|ti}nt | ot | o |g}nx|D]}ti i ||}ti i |oyti|}Wntj o qnX|i||id@o>y|i|Wqtj oti i|SqXqqUqqWdS(NiRiI(tstatR@RRRRR RRRRRR(RtOSErrortS_IMODEtST_MODERRR(RRRRRtdRtst((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyR;s2     c CsJ|}d}|}t| o*t| oti||}d}nt|oti||}n0t| ot| o |g}n|}|ot||}n|pg} g} xe|D]]} | pqntiitii | } | | jo| i | | i | qqW|i xh|D]`} | pqBntiitii | } | | jo!| i d| | i | qBqBW| }nx||}g} g}x^|D]V} tiitii | } | o+| | jo|i | | i | qqW|o|Snti ||SdS(sThis prepends newpath elements to the given oldpath. Will only add any particular path once (leaving the first one it encounters and ignoring the rest, to preserve path order), and will os.path.normpath and os.path.normcase all paths to help assure this. This can also handle the case where the given old path variable is a list instead of a string, in which case a list will be returned instead of a string. Example: Old Path: "/foo/bar:/foo" New Path: "/biz/boom:/foo" Result: "/biz/boom:/foo:/foo/bar" If delete_existing is 0, then adding a path that exists will not move it to the beginning; it will stay where it is in the list. If canonicalize is not None, it is applied to each element of newpath before use. iiN(RRR RRR)RRRtnormcaseRTtreversetinsertR(( toldpathtnewpathRtdelete_existingt canonicalizetorigtis_listtpathstnewpathsRt normpathsRR((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyt PrependPathYs\          c Cs:|}d}|}t| o*t| oti||}d}nt|oti||}n0t| ot| o |g}n|}|ot||}n|pg} g} xN|D]F} | pqn| i| | itii tii | qWxe|D]]} | pq!ntii tii | } | | jo| i| | i| q!q!W| }n||}|i g} g}x^|D]V} tii tii | } | o+| | jo|i| | i| qqW|i |o|Snti ||SdS(sThis appends new path elements to the given old path. Will only add any particular path once (leaving the last one it encounters and ignoring the rest, to preserve path order), and will os.path.normpath and os.path.normcase all paths to help assure this. This can also handle the case where the given old path variable is a list instead of a string, in which case a list will be returned instead of a string. Example: Old Path: "/foo/bar:/foo" New Path: "/biz/boom:/foo" Result: "/foo/bar:/biz/boom:/foo" If delete_existing is 0, then adding a path that exists will not move it to the end; it will stay where it is in the list. If canonicalize is not None, it is applied to each element of newpath before use. iiN( RRR RRR)RTRRRRRR(( RRRRRRRRRRRRR((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyt AppendPathsZ    )       tcygwincCs&titid|iddS(sTransforms an absolute path into a native path for the system. In Cygwin, this converts from a Cygwin path to a Windows one.s cygpath -w s R(R treplaceRtpopentread(R((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pytget_native_pathscCs|S(suTransforms an absolute path into a native path for the system. Non-Cygwin version, just leave the path alone.((R((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyRscCsKt|p t|o|Sn&t|oti|Sn|gSdS(N(RRRR R(targ((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pytSplit s  tCLVarcBs>eZdZgdZdZdZdZdZRS(sA class for command-line construction variables. This is a list that uses Split() to split an initial string along white-space arguments, and similarly to split any strings that get added. This allows us to Do the Right Thing with Append() and Prepend() (as well as straight Python foo = env['VAR'] + 'arg1 arg2') regardless of whether a user adds a list or a string to a command-line construction variable. cCsti|t|dS(N(RRGR(R&tseq((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyRGscCsti|t|S(N(Rt__add__R(R&R((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyRscCsti|t|S(N(Rt__radd__R(R&R((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyRscCs|t|fS(N(R(R&R((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyt __coerce__!scCsti|iS(N(R R(R%(R&((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyR*#s(R8R9R:RGRRRR*(((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyRs      t OrderedDictcBsqeZd dZdZdZdZdZdZdZ dZ d dZ d Z d Z RS( cCsg|_ti||dS(N(t_keysRRG(R&tdict((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyRG+s cCs$ti|||ii|dS(N(Rt __delitem__Rtremove(R&R((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyR/scCs;ti|||||ijo|ii|ndS(N(Rt __setitem__RRT(R&RR((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyR3scCsti|g|_dS(N(RtclearR(R&((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyR7s cCst}|i||S(N(Rtupdate(R&R((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyRR;s  cCst|i|iS(N(RRR(R&((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyR@scCs|iS(N(R(R&((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyRCscCsNy|id}Wntj otdnX||}||=||fS(Nisdictionary is empty(Rt IndexErrorR(R&RR((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pytpopitemFs cCs;ti|||||ijo|ii|ndS(N(Rt setdefaultRRT(R&Rtfailobj((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyRQscCs1x*|iD]\}}|i||q WdS(N(RR(R&RRR((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyRUs cCst|i|iS(N(R)RR(R&((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyRYsN(R8R9R@RGRRRRRRRRRRR(((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyR*s         tSelectorcBseZdZddZRS(sA callable ordered dictionary that maps file suffixes to dictionary values. We preserve the order in which items are added so that get_suffix() calls always return the first suffix added.c Cs1|djo1y|di}Wq>tj o d}q>Xny ||SWntj oh}xx|iD]j\}}|dj oQ|i|}|i|ot||d||fn||f||t func_codet func_globals(R>R6R9RA((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyR;s     cCs t|S(N(R(R((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyt MD5signaturesicCs)t|d}|i}|i|S(Ntrb(topenRtclose(Rt chunksizeRR((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pytMD5filesignatures  tmd5cCs)ti}|it||iS(N(thashlibRJRRt hexdigest(RRd((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyRD s cCscti}t|d}x1|i|}|pPn|it|q|i|iS(NRE(RKRJRFRRRRGRL(RRHRdRtblck((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyRIs  cCs9t|djo |dSntti|dSdS(s Collects a list of signatures into an aggregate signature. signatures - a list of signatures returns - the aggregate signature iis, N(R$RDR R((t signatures((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyt MD5collects (tinterncCs,yt|SWntj o |SnXdS(s Perform intern() on the passed argument and return the result. If the input is ineligible (e.g. a unicode string) the original argument is returned and no exception is thrown. N(RPR(R.((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyt silent_intern/stNullcBsVeZdZdZdZdZdZdZdZdZ dZ RS( s0 Null objects always and reliably "do nothing." cOs=dt|jo#tti|f|||_n|iS(Nt_inst(tvarsR-Rxt__new__RS(tclsR/R0((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyRUFs#cOsdS(N((R&R/R0((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyRGKscOs|S(N((R&R/R0((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyR3MscCsdt|S(Ns Null(0x%08X)(tid(R&((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyt__repr__OscCstS(N(R%(R&((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyR'QscCs|S(N((R&R6((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyR7SscCs|S(N((R&R6tvalue((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyt __setattr__UscCs|S(N((R&R6((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyt __delattr__Ws( R8R9R:RURGR3RXR'R7RZR[(((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyRRDs       tNullSeqcBs5eZdZdZdZdZdZRS(cCsdS(Ni((R&((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyR#[scCs tdS(N((R+(R&((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyR,]scCs|S(N((R&R`((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyR$_scCs|S(N((R&R`((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyRascCs|S(N((R&R`R((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyRcs(R8R9R#R,R$RR(((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyR\Zs     ((((((R:t __revision__RRRtos.pathR4R RHttypesRRRRyRzRRRR taltsepRR@tplatformRR RRRRR"R#R5R<RDRERURfRqRRwRR~RRRRRRRRRR>RRRRRRRRRRRR{RR(RRRRtDictionaryTypeRRRRRt can_read_regt_winregthkey_modt OpenKeyExRtEnumKeyt RegEnumKeyt EnumValuet RegEnumValuet QueryValueExRterrortRegErrort ImportErrortwin32apitwin32cont ExceptionRtHKEY_CLASSES_ROOTtHKEY_LOCAL_MACHINEtHKEY_CURRENT_USERt HKEY_USERSRRRt NameErrorRt __builtin__RR6RRRRtdisplayRRRRRR%RRRRRRR0R8R@R;RJRDRIRKRRORPRQRRR\(((s/install/lib/scons-1.2.0.d20100117/SCons/Util.pyssl                     & R                           '                      !QP    2#    N  ] )