qLc@sdZdZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl Zddl ZddlZddlZejjZejjZdefdYZdZdZdZd Zd ZyejZejZWnek r$d Zn Xd Zejd ZdZ dZ!dZ"dZ#dZ$dZ%dZ&dZ'dZ(defdYZ)de)fdYZ*dZ+da-dZ.ddZ/de*fd YZ0d!e)fd"YZ1d#e1e0fd$YZ2d%e*fd&YZ3d'e)fd(YZ4d)efd*YZ5d+efd,YZ6dS(-s SCons.Action This encapsulates information about executing any sort of action that can build one or more target Nodes (typically files) from one or more source Nodes (also typically files) given a specific Environment. The base class here is ActionBase. The base class supplies just a few OO utility methods and some generic methods for displaying information about an Action in response to the various commands that control printing. A second-level base class is _ActionAction. This extends ActionBase by providing the methods that can be used to show and perform an action. True Action objects will subclass _ActionAction; Action factory class objects will subclass ActionBase. The heavy lifting is handled by subclasses for the different types of actions we might execute: CommandAction CommandGeneratorAction FunctionAction ListAction The subclasses supply the following public interface methods used by other modules: __call__() THE public interface, "calling" an Action object executes the command or Python function. This also takes care of printing a pre-substitution command for debugging purposes. get_contents() Fetches the "contents" of an Action for signature calculation plus the varlist. This is what gets MD5 checksummed to decide if a target needs to be rebuilt because its action changed. genstring() Returns a string representation of the Action *without* command substitution, but allows a CommandGeneratorAction to generate the right action based on the specified target, source and env. This is used by the Signature subsystem (through the Executor) to obtain an (imprecise) representation of the Action operation for informative purposes. Subclasses also supply the following methods for internal use within this module: __str__() Returns a string approximation of the Action; no variable substitution is performed. execute() The internal method that really, truly, actually handles the execution of a command or Python function. This is used so that the __call__() methods can take care of displaying any pre-substitution representations, and *then* execute an action without worrying about the specific Actions involved. get_presig() Fetches the "contents" of a subclass for signature calculation. The varlist is added to this to produce the Action's contents. strfunction() Returns a substituted string representation of the Action. This is used by the _ActionAction.show() command to display the command/function that will be executed to generate the target(s). There is a related independent ActionCaller class that looks like a regular Action, and which serves as a wrapper for arbitrary functions that we want to let the user specify the arguments to now, but actually execute later (when an out-of-date check determines that it's needed to be executed, for example). Objects of this class are returned by an ActionFactory class that provides a __call__() method as a convenient way for wrapping up the functions. s9src/engine/SCons/Action.py 5023 2010/06/14 22:05:46 sconsiN(tlogInstanceCreationt_nullcBseZRS((t__name__t __module__(((s\/home/als/proj/qrscanner/ext/qrscanner/zxing/scons/scons-local-2.0.0.final.0/SCons/Action.pyRzsiicCs'y|jSWntk r"|SXdS(N(trfiletAttributeError(tn((s\/home/als/proj/qrscanner/ext/qrscanner/zxing/scons/scons-local-2.0.0.final.0/SCons/Action.pyRs cCs|S(N((ts((s\/home/als/proj/qrscanner/ext/qrscanner/zxing/scons/scons-local-2.0.0.final.0/SCons/Action.pytdefault_exitstatfuncscCs|S(N((tx((s\/home/als/proj/qrscanner/ext/qrscanner/zxing/scons/scons-local-2.0.0.final.0/SCons/Action.pytscCsg}t|}d}x}||kr||}t|}|tkr}|tkrp|j|||d!n|d}q|j||d}qWdj|S(Niiit(tlentordt HAVE_ARGUMENTt SET_LINENOtappendtjoin(tcodetresultRtitctop((s\/home/als/proj/qrscanner/ext/qrscanner/zxing/scons/scons-local-2.0.0.final.0/SCons/Action.pytremove_set_lineno_codess       s^['"](.*)['"]$cCszyt|jSWnbtk ruyt|jjSWqvtk rqyt|SWqrtk rmt|SXqvXnXdS(s?Return the signature contents of a callable Python object. N(t_function_contentstim_funcRt__call__t_code_contents(tobj((s\/home/als/proj/qrscanner/ext/qrscanner/zxing/scons/scons-local-2.0.0.final.0/SCons/Action.pyt_callable_contentss   cCsyt|jSWntk ryt|jjSWqtk ryt|SWqtk ryt|SWqtk rytj|SWqtjtfk rt |SXqXqXqXnXdS(sReturn the signature contents of any Python object. We have to handle the case where object contains a code object since it can be pickled directly. N( RRRRRtpickletdumpst PicklingErrort TypeErrortstr(R((s\/home/als/proj/qrscanner/ext/qrscanner/zxing/scons/scons-local-2.0.0.final.0/SCons/Action.pyt_object_contentss     cCsg}|jd|jt|jfy-|jdt|jt|jfWntk rv|jdnX|jddjtt |j dd|jddjtt |j d|jdt t |jddj|S( sReturn the signature contents of a code object. By providing direct access to the code object of the function, Python makes this extremely easy. Hooray! Unfortunately, older versions of Python include line number indications in the compiled byte code. Boo! So we remove the line number byte codes to prevent recompilations from moving a Python function. s%s,%ss,%s,%ss,0,0s,(t,it)R (Rt co_argcountR t co_varnamest co_cellvarst co_freevarsRRtmapR#t co_conststco_namesR"Rtco_code(Rtcontents((s\/home/als/proj/qrscanner/ext/qrscanner/zxing/scons/scons-local-2.0.0.final.0/SCons/Action.pyRs #-  .*$cCst|jg}|jrH|jddjtt|jdn |jdy|jpdg}Wntk rg}nXy&g|D]}t|j ^q}Wntk rg}nX|jddj|ddj|S(s,Return the signature contents of a function.s,(R$R%s,()R ( Rt func_codet func_defaultsRRR*R#t func_closureRt cell_contents(tfuncR.tclosureR txxx((s\/home/als/proj/qrscanner/ext/qrscanner/zxing/scons/scons-local-2.0.0.final.0/SCons/Action.pyR s -   &  cCst|}t|}|dks0|dkrUtdt|t|fnt|trt|trt|j|jSt|j|gSn3t|trt|g|jSt||gSdS(NsCannot append %s to %s(tActiontNoneR!ttypet isinstancet ListActiontlist(tact1tact2ta1ta2((s\/home/als/proj/qrscanner/ext/qrscanner/zxing/scons/scons-local-2.0.0.final.0/SCons/Action.pyt _actionAppend)s  %cCs|jdd }t|r*|f}nt||d<|r|d}|dksbt|ro||d| r$t | jdjdj}q:t |dj}q>qAXn|r| rh| j}| j}ndjtt |} dj|j|} d| | f} tjj| nd}|r|jr| r| j}| j}ny|j|||| }Wn&tk r5|j|||}nX|r|rYdt||}ny |j}Wnt k r|j}nX|d}|s|j}n|||||qnd}|rc|rt j|nzj|j|||d| }t |t!j"j#r9||j$}|r0||_$qE|}n ||}Wd| r_t j| nXn|r| r|dt| |||n|S( Nis and s uBuilding %s with action: %s s os.chdir(%s) tPRINT_CMD_LINE_FUNCRzs os.chdir(%s)(%RRRRtprint_actions_presubRt print_actionstexecute_actionsRR7tostgetcwdR"tabspathRREtbatchesR{tdirtget_all_targetstget_all_sourcesRR*RyRRRRCR!treprRDRtexecuteR9RHRIt BuildErrortstatus(RgRkRlRjRRtshowRRRztsave_cwdtttltouttcmdRDt print_functstatR((s\/home/als/proj/qrscanner/ext/qrscanner/zxing/scons/scons-local-2.0.0.final.0/SCons/Action.pyRs                            (N(RRR}RR7RRR(((s\/home/als/proj/qrscanner/ext/qrscanner/zxing/scons/scons-local-2.0.0.final.0/SCons/Action.pyRs   cCscg}xMtt|D]<}d|ks4d|krEd|d}n|j|qWdj|S(s\Takes a list of command line arguments and returns a pretty representation for printing.t s t"(R*R"RR(tcmd_listtcltarg((s\/home/als/proj/qrscanner/ext/qrscanner/zxing/scons/scons-local-2.0.0.final.0/SCons/Action.pyt_string_from_cmd_listIs cCsMy |dSWn:tk rHtsDddl}|jjdantSXdS(NtENVi(RTt default_ENVtSCons.Environmentt Environment(RjRH((s\/home/als/proj/qrscanner/ext/qrscanner/zxing/scons/scons-local-2.0.0.final.0/SCons/Action.pytget_default_ENVYs   tignorec Ks|jd}t|r=|dkr=ttj|d|jD]3}x*|j||||D]}t||Msd                      & .    /  7v   5Y){8F