Ñò rê$Lc @s-dZdZddkZddkZddkZddklZlZei i ei i ei i gZ e efad„Zd„Zdefd„ƒYZd efd „ƒYZd „Zd eifd „ƒYZd„Zdefd„ƒYZdeifd„ƒYZdefd„ƒYZdei ifd„ƒYZeƒZd„Z dZ!dZ"dZ#ei$dƒZ%ei$dƒZ&e%e'e&gZ(d„Z)d„Z*e)e'e*gZ+dZ,ei$d e,ƒZ-ei$d!e,ƒZ.ei$d"ƒZ/e"e'e'hhe'd#„Z0e"e'e'hhe'd$„Z1d%„Z2dS(&s)SCons.Subst SCons string substitution. s8src/engine/SCons/Subst.py 5023 2010/06/14 22:05:46 sconsiÿÿÿÿN(t is_Stringt is_SequencecGs0g}|D]}|o ||q q ~adS(N(tAllowableExceptions(texceptst_[1]t_f((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pytSetAllowableExceptions/scCsY|ii}d|||f}|otii|d|ƒ‚ntii|ƒ‚dS(Ns%s `%s' trying to evaluate `%s'i(t __class__t__name__tSConstErrorst BuildErrort UserError(t exceptionttargettstnametmsg((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pytraise_exception3s  tLiteralcBs;eZdZd„Zd„Zd„Zd„Zd„ZRS(sÌA wrapper for a string. If you use this object wrapped around a string, then it will be interpreted as literal. When passed to the command interpreter, all special characters will be escaped.cCs ||_dS(N(tlstr(tselfR((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyt__init__BscCs|iS(N(R(R((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyt__str__EscCs ||iƒS(N(R(Rt escape_func((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pytescapeHscCs|iS(N(R(R((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyt for_signatureKscCsdS(Ni((R((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyt is_literalNs(Rt __module__t__doc__RRRRR(((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyR=s     tSpecialAttrWrappercBs>eZdZdd„Zd„Zd„Zd„Zd„ZRS(sÃThis is a wrapper for what we call a 'Node special attribute.' This is any of the attributes of a Node that we can reference from Environment variable substitution, such as $TARGET.abspath or $SOURCES[1].filebase. We implement the same methods as Literal so we can handle special characters, plus a for_signature method, such that we can return some canonical string during signature calculation to avoid unnecessary rebuilds.cCs*||_|o ||_n ||_dS(s˜The for_signature parameter, if supplied, will be the canonical string we return from for_signature(). Else we will simply return lstr.N(Rtforsig(RRR((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyRZs  cCs|iS(N(R(R((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyRdscCs ||iƒS(N(R(RR((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyRgscCs|iS(N(R(R((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyRjscCsdS(Ni((R((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyRmsN( RRRtNoneRRRRR(((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyRQs    cCs1d|jp d|jo d|St|ƒSdS(s\Generic function for putting double quotes around any string that has white space in it.t s s"%s"N(tstr(targ((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyt quote_spacesps tCmdStringHoldercBs/eZdZdd„Zd„Zed„ZRS(s6This is a special class used to hold strings generated by scons_subst() and scons_subst_list(). It defines a special method escape(). When passed a function with an escape algorithm for a particular platform, it will return the contained string with the proper escape sequences inserted. cCs tii||ƒ||_dS(N(t collectionst UserStringRtliteral(RtcmdR(((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyRscCs|iS(N(R((R((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyRƒscCsT|iƒo||iƒSd|ijpd|ijo||iƒS|iSdS(sOEscape the string with the supplied function. The function is expected to take an arbitrary string, then return it with all special characters escaped and ready for passing to the command interpreter. After calling this function, the next call to str() will return the escaped string. R!s N(Rtdata(RRt quote_func((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyR†s  N(RRRR RRR$R(((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyR%xs  cCs|d„}tt||ƒƒS(s|Escape a list of arguments by running the specified escape_func on every object in the list that has an escape() method.cSs2y |i}Wntj o|SX||ƒSdS(N(RtAttributeError(tobjRte((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyRšs  (tlisttmap(tmylistRR((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyt escape_list—s t NLWrappercBs/eZdZd„Zd„Zd„ZeZRS(s9A wrapper class that delays turning a list of sources or targets into a NodeList until it's needed. The specified function supplied when the object is initialized is responsible for turning raw nodes into proxies that implement the special attributes like .abspath, .source, etc. This way, we avoid creating those proxies just "in case" someone is going to use $TARGET or the like, and only go through the trouble if we really have to. In practice, this might be a wash performance-wise, but it's a little cleaner conceptually... cCs||_||_dS(N(R/tfunc(RR/R4((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyR°s cCs|iS(N(tnodelist(R((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyt_return_nodelist³scCst|i}|djo g}nt|ƒp |g}ntiitt|i|ƒƒƒ|_|i |_ |iS(N( R/R RR tUtiltNodeListR0R4R5R6t_create_nodelist(RR1((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyt _gen_nodelistµs     ' (RRRRR6R:R9(((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyR3£s     tTargets_or_SourcescBsDeZdZd„Zd„Zd„Zd„Zd„Zd„ZRS(sÒA class that implements $TARGETS or $SOURCES expansions by in turn wrapping a NLWrapper. This class handles the different methods used to access the list, calling the NLWrapper to create proxies on demand. Note that we subclass collections.UserList purely so that the is_Sequence() function will identify an object of this class as a list during variable expansion. We're not really using any collections.UserList methods in practice. cCs ||_dS(N(tnl(RR<((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyRÍscCs|iiƒ}t||ƒS(N(R<R9tgetattr(RtattrR<((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyt __getattr__ÏscCs|iiƒ}||S(N(R<R9(RtiR<((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyt __getitem__ÒscCs8|iiƒ}t|dƒ}t|dƒ}|||!S(Ni(R<R9tmax(RR@tjR<((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyt __getslice__ÕscCs|iiƒ}t|ƒS(N(R<R9R"(RR<((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyRÙscCs|iiƒ}t|ƒS(N(R<R9trepr(RR<((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyt__repr__Üs( RRRRR?RARDRRF(((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyR;Ãs      tTarget_or_SourcecBs2eZdZd„Zd„Zd„Zd„ZRS(síA class that implements $TARGET or $SOURCE expansions by in turn wrapping a NLWrapper. This class handles the different methods used to access an individual proxy Node, calling the NLWrapper to create a proxy on demand. cCs ||_dS(N(R<(RR<((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyRæscCsP|iiƒ}y|d}Wn#tj otd|ƒ‚nXt||ƒS(NisNodeList has no attribute: %s(R<R9t IndexErrorR,R=(RR>R<tnl0((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyR?ès cCs)|iiƒ}|ot|dƒSdS(Nit(R<R9R"(RR<((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyRñscCs)|iiƒ}|ot|dƒSdS(NiRJ(R<R9RE(RR<((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyRFös(RRRRR?RRF(((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyRGàs   t NullNodeListcBseZd„Zd„ZRS(cOsdS(NRJ((Rtargstkwargs((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyt__call__ýscCsdS(NRJ((R((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyRþs(RRRNR(((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyRKüs cCsàh}|oPd„}t||ƒ}t|ƒ|d[ss$)(tappend(R/tresultt do_appendRd((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyt _remove_listVs     s'\$[\$\(\)]|\$[_a-zA-Z][\.\w]*|\${[^}]*}s(%s)s(%s|\s+|[^\s\$]+|\$)s[\t ]+(?![^{]*})c Cs‰t|tƒo|idƒdjo|Sdtfd„ƒY}|d jot|}nd|jo7t||ƒ} | o|iƒ}|i| ƒq nt |d<|||||ƒ} | i ||ƒ} y |d=Wnt j onXt | ƒoTt |} | o| id| ƒ} n|tjotid| ƒiƒ} q…n3t| ƒo%t|} | o| | ƒ} q…n| S( sTExpand a string or list containing construction variable substitutions. This is the work-horse function for substitutions in file names and the like. The companion scons_subst_list() function (below) handles separating command lines into lists of arguments, so see that function if that's what you're looking for. t$it StringSubbercBs)eZdZd„Zd„Zd„ZRS(sëA class to construct the results of a scons_subst() call. This binds a specific construction environment, mode, target and source with two methods (substitute() and expand()) that handle the expansion. cSs(||_||_||_||_dS(N(tenvtmodetconvtgvars(RRnRoRpRq((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyR•s   c SsÆt|ƒoÕy|d \}}Wnttfj o|SX|djo|S|djodS|djo|S|d}|ddjp|idƒdjo•|ddjo|dd!}nyt||i|ƒ}Wq¥tj o ‚q¥tj o2}|it jod St ||d |ƒq¥Xnl||jo||}nQ||ijo|i|}n0t t jot t |ƒ|d |ƒnd S|i ƒ}|i dƒd}d ||<|i||ƒSnát|ƒo,|i|i|d „} tt| |ƒƒSt|ƒo„y9|d |d d |dd|id|itjƒ}Wn7tj o+|itjo|S|i|ƒ}nX|i||ƒS|djod S|SdS(sÐExpand a single "token" as necessary, returning an appropriate string containing the expansion. This handles expanding different types of things (strings, lists, callables) appropriately. It calls the wrapper substitute() method to re-expand things as necessary, so that the results of expansions of side-by-side strings still get re-evaluated separately, not smushed together. iRls()iit{t.iÿÿÿÿRJRScSs||||ƒƒS(N((RdRpt substitutetlvars((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyR4ØsRR_RZRnRN(RRHt ValueErrortfindtevalRqtKeyboardInterruptt ExceptionRRRt NameErrortcopytsplitRtRRpR/R0tcallableRnRot SUBST_CMDt TypeErrort SUBST_RAWR ( RRRuts0ts1tkeyR.tlvtvarR4((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pytexpand›sf     '         cst|ƒoát|tƒ oÐt|ƒ}y(‡‡fd†}ti||ƒ}Wn”tj oˆti|ƒ}g}x0|D](}|i ˆi ˆi |ˆƒƒƒqWt |ƒdjo|d}qédi tt|ƒƒ}nX|Sˆi |ˆƒSdS(s©Substitute expansions in an argument or list of arguments. This serves as a wrapper for splitting up a string into separate tokens. cs"ˆiˆi|idƒˆƒƒS(Ni(RpR‡tgroup(tmatch(RRu(s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyt sub_match÷siiRJN(Rt isinstanceR%R"t _dollar_expstsubR€t_separate_argstfindallRhRpR‡tlentjoinR0(RRLRuRŠRita((RRus.install/lib/scons-2.0.0.final.0/SCons/Subst.pyRtîs  &(RRRRR‡Rt(((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyRmŽs  SRTt __builtins__RJR!N(R‹R"RwtobjectR t_strconvRcR|tupdateR“RttKeyErrorRt _regex_removeRRt _space_septstripRt _list_remove( tstrSubstRnRoRR_RqRuRpRmtdtssRitremove((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyt scons_subst‚s8 &~           c CsÒdtifd„ƒY}|djot|}nd|jo7t||ƒ} | o|iƒ}|i| ƒqxnt|d<|||||ƒ} | i||dƒy |d=Wnt j onX| i S(s&Substitute construction variables in a string (or list or other object) and separate the arguments into a command list. The companion scons_subst() function (above) handles basic substitutions within strings, so see that function instead if that's what you're looking for. t ListSubbercBsqeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z RS( sA class to construct the results of a scons_subst_list() call. Like StringSubber, this class binds a specific construction environment, mode, target and source with two methods (substitute() and expand()) that handle the expansion. In addition, however, this class is used to track the state of the result(s) we're gathering so we can do the appropriate thing whenever we have to append another word to the result--start a new line, start a new word, append to the current word, etc. We do this by setting the "append" attribute to the right method so that our wrapper methods only need ever call ListSubber.append(), and the rest of the object takes care of doing the right thing internally. cs€tiiˆgƒ|ˆ_|ˆ_|ˆ_|ˆ_ˆitjo‡fd†ˆ_n d„ˆ_dˆ_ ˆi ƒdS(Ncs ˆi|ƒS((Rh(Rf(R(s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyRggscSsdS(N(R (Rf((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyRgis( R&tUserListRRnRoRpRqRt add_stripR tin_stript next_line(RRnRoRpRq((Rs.install/lib/scons-2.0.0.final.0/SCons/Subst.pyR_s      c SsKt|ƒo/y|d \}}Wn'ttfj o|i|ƒdSX|djo|i|ƒdS|djo|idƒqG|djo|idƒqG|djo|idƒqG|d}|d d jp|id ƒd jo•|d d jo|dd !}nyt||i|ƒ}Wqòt j o ‚qòt j o2}|i t jodSt ||d |ƒqòXni||jo||}nN||ijo|i|}n-tt jot tƒ|d |ƒndS|iƒ}|id ƒd } d|| <|i||d ƒ|iƒn t|ƒo2xû|D]#} |i| |dƒ|iƒqPWnÍt|ƒo—y9|d|d d|dd|id|itjƒ}WnDtj o8|itjo|i|ƒdS|i|ƒ}nX|i|||ƒn)|djo|iƒn|i|ƒdS(sÅExpand a single "token" as necessary, appending the expansion to the current result. This handles expanding different types of things (strings, lists, callables) appropriately. It calls the wrapper substitute() method to re-expand things as necessary, so that the results of expansions of side-by-side strings still get re-evaluated separately, not smushed together. iNRlt(s$(t)s$)iiRrRsiÿÿÿÿRSRJRR_RZRnR(RRHRvRht open_stript close_stripRwRxRqRyRzRRRR{R|R}Rtt this_wordRt next_wordR~RnRoRR€RRpR ( RRRut within_listR‚RƒR„R.R…R†R’((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyR‡msv        '          cSsÊt|ƒo¦t|tƒ o•t|ƒ}ti|ƒ}xŠ|D]k}|ddjoAd|jo|iƒq«|o|i|ƒq«|iƒq@|i |||ƒq@Wn|i |||ƒdS(s©Substitute expansions in an argument or list of arguments. This serves as a wrapper for splitting up a string into separate tokens. is s N( RR‹R%R"RŽRR¥RhR«R‡(RRLRuR¬R’((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyRtÀs  cSs!tii|gƒ|iƒdS(s£Arrange for the next word to start a new line. This is like starting a new word, except that we have to append another line to the result.N(R&R¢RhR«(R((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyR¥×scSs|i|_dS(sbArrange for the next word to append to the end of the current last word in the result.N(tadd_to_current_wordRh(R((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyRªÞscSs|i|_dS(s.Arrange for the next word to start a new word.N(t add_new_wordRh(R((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyR«ãsc Ssí|i p|itjoÎy|dd}Wn tj o|i|ƒqéXyt|ƒd}Wntj o d}nX|djo|i|ƒqé||}|i|ƒ}t|ƒot|dƒ}n||dd|N( R¤Rot SUBST_SIGRHR®R"RpRR%R (RRft current_wordt last_charty((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyR­çs      cSs~|i p|itjoS|i|ƒ}|i|ƒ}t|ƒot||ƒ}n|di|ƒn|i|_dS(Niÿÿÿÿ( R¤RoR°R(RpRR%RhR­(RRfR(((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyR®s cSs/y |i}Wntj odSX|ƒSdS(N(RR,R (RRfRd((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyR( s  cSs|i|ƒd|_dS(s!Handle the "open strip" $( token.iN(R£R¤(RRf((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyR¨(s cSs|i|ƒd|_dS(s"Handle the "close strip" $) token.N(R£R R¤(RRf((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyR©-s (RRRRR‡RtR¥RªR«R­R®R(R¨R©(((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyR¡Os  S     0  RTR“iN( R&R¢R R•RcR|R–R“RtR—R*( RœRnRoRR_RqRuRpR¡Rtls((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pytscons_subst_listAs ã     cCs,t|tƒo|idƒdjo|Sd|d|dg}|i|dƒ}||d„}t|ƒo•g}x‡|D]}t|ƒo_||jo5|}t|ƒo|i|ƒqì|i|ƒqý|iti ||ƒƒq~|i|ƒq~W|St|ƒoti ||ƒS|SdS(sPerform single (non-recursive) substitution of a single construction variable keyword. This is used when setting a variable when copying or overriding values in an Environment. We want to capture (expand) the old value before we override it, so people can do things like: env2 = env.Clone(CCFLAGS = '$CCFLAGS -g') We do this with some straightforward, brute-force code here... Rlis${t}RJcSsX|idƒ}||jo |}nt|ƒoditt|ƒƒSt|ƒSdS(NiR!(RˆRR‘R0R"(R‰tvalt matchlistR’((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pyRŠgs    N( R‹R"RwtgetRRtextendRhRŒR(RœRnR„R¸R·RŠRiR#((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pytscons_subst_onceVs* &     (3Rt __revision__R&tret SCons.ErrorsR t SCons.UtilRRR7tto_String_for_substtto_String_for_signatureR•RHR{RRRR”RRR$R'R%R2R3R¢R;RGtNullSeqRKR^RcRRR°tcompilet_rmt_removeR R˜ReRkR›t_dollar_exps_strRŒRŽR™R RµR»(((s.install/lib/scons-2.0.0.final.0/SCons/Subst.pytsN             F  ¿ÿ