ó LzńWc@s™dZddlZddlZddlZddlmZmZdefd„ƒYZdefd„ƒYZdefd „ƒYZ d d d „ƒYZ dS( sP This module contains all the classes used to manage the building dependencies. i˙˙˙˙N(t_tmsgtDependcBsteZdZd iid„Zd„Zd„Zdd„Zd„Zd„Z d„Z d „Z d „Z d „Z RS( sG This is a base class to represent file dependencies. It provides the base functionality of date checking and recursive making, supposing the existence of a method `run()' in the object. This method is supposed to rebuild the files of this node, returning zero on success and something else on failure. cCsV||_|r||_n g|_|jƒ||_d|_d|_||_dS(s{ Initialize the object for a given set of output files and a given set of sources. The argument `prods' is a list of file names, and the argument `sources' is a dictionary that associates file names with dependency nodes. The optional argument `loc' is a dictionary that describes where in the sources this dependency was created. iN(tenvtprodstset_datetsourcestmakingtNonet failed_deptloc(tselfRRRR ((sA/usr/lib/python2.7/dist-packages/dbtexmf/dblatex/grubber/maker.pyt__init__s       cCsa|jgkrd|_nBy%tttjj|jƒƒ|_Wntk r\d|_nXdS(sÖ Define the date of the last build of this node as that of the most recent file among the products. If some product does not exist or there are ne products, the date is set to None. N( RRtdatetmaxtmaptostpathtgetmtimetOSError(R ((sA/usr/lib/python2.7/dist-packages/dbtexmf/dblatex/grubber/maker.pyR(s  % cCsA|js dSx-|jjƒD]}|j|jkrdSqWdS(sĽ Check the dependencies. Return true if this node has to be recompiled, i.e. if some dependency is modified. Nothing recursive is done here. ii(R Rtvalues(R tsrc((sA/usr/lib/python2.7/dist-packages/dbtexmf/dblatex/grubber/maker.pyt should_make<s  icCs|jrdGHdSd|_d|_|}x]|jjƒD]L}|jƒ}|dkrqd|_|j|_dS|dkr:d}q:q:W|sœ|jƒrű|rą|jƒ}n |jƒ}|rŮd|_||_dSt t j ƒƒ|_ d|_dSd|_dS(sŕ Make the destination file. This recursively makes all dependencies, then compiles the target if dependencies were modified. The semantics of the return value is the following: - 0 means that the process failed somewhere (in this node or in one of its dependencies) - 1 means that nothing had to be done - 2 means that something was recompiled (therefore nodes that depend on this one have to be remade) sFIXME: cyclic makeiiiN( RRR RRtmakeRt force_runtruntintttimeR (R tforcet must_makeRtret((sA/usr/lib/python2.7/dist-packages/dbtexmf/dblatex/grubber/maker.pyRHs6               cCs |jƒS(sŒ This method is called instead of 'run' when rebuilding this node was forced. By default it is equivalent to 'run'. (R(R ((sA/usr/lib/python2.7/dist-packages/dbtexmf/dblatex/grubber/maker.pyR}scCs|jS(s’ Return a reference to the node that caused the failure of the last call to "make". If there was no failure, return None. (R (R ((sA/usr/lib/python2.7/dist-packages/dbtexmf/dblatex/grubber/maker.pytfailed„sccsdrdVndS(sT Report the errors that caused the failure of the last call to run. N(R(R ((sA/usr/lib/python2.7/dist-packages/dbtexmf/dblatex/grubber/maker.pyt get_errors‹scCs~xJ|jD]?}tjj|ƒr tjtdƒ|ƒtj|ƒq q Wx!|jj ƒD]}|j ƒq]Wd|_ dS(sh Remove the files produced by this rule and recursively clean all dependencies. s removing %sN( RRRtexistsRtlogRtunlinkRRtcleanRR (R tfileR((sA/usr/lib/python2.7/dist-packages/dbtexmf/dblatex/grubber/maker.pyR$’scCsdS(sB Reinitializing depends on actual dependency leaf N((R ((sA/usr/lib/python2.7/dist-packages/dbtexmf/dblatex/grubber/maker.pytreinitŸscCsM|jikr|jSg}x*|jjƒD]}|j|jƒƒq,W|S(s— Return a list of all source files that are required by this node and cannot be built, i.e. the leaves of the dependency tree. (RRRtextendtleaves(R Rtdep((sA/usr/lib/python2.7/dist-packages/dbtexmf/dblatex/grubber/maker.pyR(Ľs N(t__name__t __module__t__doc__RR RRRRRR R$R&R((((sA/usr/lib/python2.7/dist-packages/dbtexmf/dblatex/grubber/maker.pyR s  5    t DependLeafcBs)eZdZd„Zd„Zd„ZRS(sc This class specializes Depend for leaf nodes, i.e. source files with no dependencies. cOs#tj||dt|ƒ|dS(s Initialize the node. The arguments of this method are the file names, since one single node may contain several files. RN(RR tlist(R Rtdesttargs((sA/usr/lib/python2.7/dist-packages/dbtexmf/dblatex/grubber/maker.pyR ˇscCs`t|jƒdkr<tjtdƒ|jd|jn tjtdƒ|j|jdS(Nis%r does not existisone of %r does not exist(tlenRRterrorRR (R ((sA/usr/lib/python2.7/dist-packages/dbtexmf/dblatex/grubber/maker.pyRžs' cCsdS(N((R ((sA/usr/lib/python2.7/dist-packages/dbtexmf/dblatex/grubber/maker.pyR$Ćs(R*R+R,R RR$(((sA/usr/lib/python2.7/dist-packages/dbtexmf/dblatex/grubber/maker.pyR-˛s  t DependShellcBs eZdZd„Zd„ZRS(sR This class specializes Depend for generating files using shell commands. cKs tj|||||_dS(N(RR tcmd(R RR4R0((sA/usr/lib/python2.7/dist-packages/dbtexmf/dblatex/grubber/maker.pyR ÎscCsktjtdƒ|jdƒtj|jdtjƒ}|dkrgtjtdƒ|jdƒdSdS(Ns running %sitstdoutsexecution of %s failedi(RtprogressRR4t subprocesstcallR5R2(R trc((sA/usr/lib/python2.7/dist-packages/dbtexmf/dblatex/grubber/maker.pyRŇs  (R*R+R,R R(((sA/usr/lib/python2.7/dist-packages/dbtexmf/dblatex/grubber/maker.pyR3Ęs tMakercBs>eZdZd„Zd„Zd„Zdd„Zd„ZRS(sa Very simple builder environment. Much simpler than the original rubber Environment. cCs g|_dS(N(t dep_nodes(R ((sA/usr/lib/python2.7/dist-packages/dbtexmf/dblatex/grubber/maker.pyR ŕscCs|js dS|jdSdS(Ni˙˙˙˙(R;R(R ((sA/usr/lib/python2.7/dist-packages/dbtexmf/dblatex/grubber/maker.pytdep_lastăs cCs|jj|ƒdS(N(R;tappend(R R)((sA/usr/lib/python2.7/dist-packages/dbtexmf/dblatex/grubber/maker.pyt dep_appendésicCs>|js dS|jdjd|ƒ}|dkr6dSdSdS(Nii˙˙˙˙R(R;R(R RR9((sA/usr/lib/python2.7/dist-packages/dbtexmf/dblatex/grubber/maker.pyRěs   cCs|jƒdS(N(R (R ((sA/usr/lib/python2.7/dist-packages/dbtexmf/dblatex/grubber/maker.pyR&ös(R*R+R,R R<R>RR&(((sA/usr/lib/python2.7/dist-packages/dbtexmf/dblatex/grubber/maker.pyR:Űs     (( R,RRR7RRtobjectRR-R3R:(((sA/usr/lib/python2.7/dist-packages/dbtexmf/dblatex/grubber/maker.pyts   Ľ