^Rc@sdZddlZddlZddlZddlZddlZdddgZddddddZddddd Z d dddd Z d Z d Z e dkree ZejendS(sModule/script to byte-compile all .py files to .pyc (or .pyo) files. When called as a script with arguments, this compiles the directories given as arguments recursively; the -l option prevents it from recursing into directories. Without arguments, if compiles all modules on sys.path, without recursing into subdirectories. (Even though it should do so for packages -- for now, you'll have to deal with packages separately.) See module py_compile for details of the actual byte-compilation. iNt compile_dirt compile_filet compile_pathi ic Csc|sdG|GdGHnytj|}Wn#tjk rNdG|GHg}nX|jd}x|D]}tjj||} |dk rtjj||} nd} tjj| st| ||||s[d}q[qf|dkrf|tj krf|tj krftjj| rftjj |  rft | |d| |||s[d}q[qfqfW|S(sByte-compile all modules in the given directory tree. Arguments (only dir is required): dir: the directory to byte-compile maxlevels: maximum recursion level (default 10) ddir: the directory that will be prepended to the path to the file as it is compiled into each byte-code file. force: if 1, force compilation, even if timestamps are up-to-date quiet: if 1, be quiet during compilation tListings...s Can't listiiN( tostlistdirterrortsorttpathtjointNonetisdirRtcurdirtpardirtislinkR( tdirt maxlevelstddirtforcetrxtquiettnamestsuccesstnametfullnametdfile((s /usr/lib/python2.7/compileall.pyRs2         cCsd}tjj|}|d k r<tjj||}nd }|d k rj|j|}|rj|Sntjj|r|d |d} } | dkr|s>yttj|j } t j dt j | } |trdpd} t| d}|jd}Wd QX| |kr&|SWq>tk r:q>Xn|sTd G|Gd GHnytj|d |t}Wn[tjk r}|rd G|Gd GHn|jGHd }qtk r}d G|GHd }qX|d krd }qqn|S(sIByte-compile one file. Arguments (only fullname is required): fullname: the file to byte-compile ddir: if given, the directory name compiled in to the byte-code file. force: if 1, force compilation, even if timestamps are up-to-date quiet: if 1, be quiet during compilation iis.pys<4sltctotrbiNt Compilings...itSorry(RRtbasenameR R tsearchtisfiletinttstattst_mtimetstructtpacktimpt get_magict __debug__topentreadtIOErrort py_compiletcompiletTruetPyCompileErrortmsg(RRRRRRRRtmotheadttailtmtimetexpecttcfiletchandletactualtokterrte((s /usr/lib/python2.7/compileall.pyR=sL          ic Cscd}xVtjD]K}| s,|tjkr:|r:dGHq|oXt||d|d|}qW|S(sByte-compile all module on sys.path. Arguments (all optional): skip_curdir: if true, skip current directory (default true) maxlevels: max recursion level (default 0) force: as for compile_dir() (default 0) quiet: as for compile_dir() (default 0) isSkipping current directoryRN(tsysRRR RR (t skip_curdirRRRRR((s /usr/lib/python2.7/compileall.pyRqs cCs|}|ryU|dkr(tj}n t|}x*|j}|sMPn|j|d q7Wqtk rd|GHqXn|S(s&read names in flist and append to argst-isError reading file list %s(R=tstdinR*treadlinetappendR,(targstflisttexpandedtfdtline((s /usr/lib/python2.7/compileall.pyt expand_argss       c Csddl}y#|jtjdd\}}Wnk|jk r}|GHdGHHdGHdGHHdGHd GHd GHd GHd GHd GHdGHdGHdGHdGHtjdnXd}d}d}d}d}d} x|D]\} } | dkrd}n| dkr| }n| dkrd}n| dkr(d}n| dkrRddl} | j| }n| dkr| } qqW|rt|dkrt j j |d rdGHtjdqnd} y|s| rty| rt || }nWnt k rd} nX| r}xk|D]`}t j j |rIt||||||sjd} qjq t|||||s d} q q Wq}n t} Wntk rdGHd} nX| S(sScript main program.iNis lfqd:x:i:sbusage: python compileall.py [-l] [-f] [-q] [-d destdir] [-x regexp] [-i list] [directory|file ...]sTarguments: zero or more file and directory names to compile; if no arguments given, s4 defaults to the equivalent of -l sys.pathsoptions:s%-l: don't recurse into subdirectoriess3-f: force rebuild even if timestamps are up-to-dates-q: output only error messagessX-d destdir: directory to prepend to file paths for use in compile-time tracebacks and insL runtime tracebacks in cases where the source file is unavailablesX-x regexp: skip files matching the regular expression regexp; the regexp is searched forsC in the full path of each file considered for compilationsT-i file: add all the files and directories listed in file to the list considered fors7 compilation; if "-", names are read from stdinii is-ls-ds-fs-qs-xs-is1-d destdir require exactly one directory arguments [interrupted](tgetoptR=targvRtexitR treR.tlenRRR RHR,RRRtKeyboardInterrupt(RItoptsRCR1RRRRRRDRtaRLRtarg((s /usr/lib/python2.7/compileall.pytmains #       )         t__main__(t__doc__RR=R-R%R't__all__R RRRRHRRt__name__R"t exit_statusRK(((s /usr/lib/python2.7/compileall.pyt s     '4  J