�`^c@s�dZddlZddlZddlZddlZddlZdddgZdddddd�Zddddd �Z d
dddd�Z
d�Zd
�Ze
dkr�ee��Zeje�ndS(s�Module/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.
i�Ntcompile_dirtcompile_filetcompile_pathi
icCsc|sdG|GdGHnytj|�}Wn#tjk
rNdG|GHg}nX|j�d}x�D]�tjj||�} |dk r�tjj||�}
nd}
tjj| �s�| ||||�s[d}q[qf|dkrf|tj krf|tj
krftjj| �rftjj| �rft| |d|
|||�s[d}q[qfqfW|S(s�Byte-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 /sys/lib/python2.7/compileall.pyRs2
cCs�d}tjj|�}|d k r<tjj||�}nd }|d k rj|j|�}|rj|Sntjj|�r�d |d} }
|
dkr�s>y�ttj|�j �}t
jdtj
�|�}|tr�p�}
t|
d��}|jd�}Wd QX||kr&|SWq>tk
r:q>Xn|sTd
G|GdGHnytj|d |t�}Wn[tjk
r�}|r�d
G|GdGHn|jGHd}q�tk
r�}d
G|GHd}q�|dkr�}q��|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
ii�s.pys<4sltctotrbiNt Compilings...itSorry(RRtbasenameR
R tsearchtisfiletinttstattst_mtimetstructtpacktimpt get_magict __debug__topentreadtIOErrort
py_compiletcompiletTruetPyCompileErrortmsg(RRRRRRRRtmotheadttailtmtimetexpecttcfiletchandletactualtokterrte((s /sys/lib/python2.7/compileall.pyR=sL
icCscd}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(tsysRRRRR
(tskip_curdirRRRRR((s /sys/lib/python2.7/compileall.pyRqs
cCs�|}|r�yU|dkr(tj}nt|�}x*|j�}|sMPn|j|d �q7Wq�tk
r�d|GH�q�Xn|S(s&read names in flist and append to argst-i�sError reading file list %s(R=tstdinR*treadlinetappendR,(targstflisttexpandedtfdtline((s /sys/lib/python2.7/compileall.pytexpand_args�s
cCs�ddl}y#|jtjdd�\}}Wnk|jk
r�}|GHdGHHdGHdGHHdGHd GHd
GHdGHdGHd
GHdGHdGHdGHdGHtjd�nXd}d}d}d}d}d} x�|D]�\}
}|
dkr�}n|
dkr�}n|
dkrd}n|
dkr(d}n|
dkrRddl}|j|�}n|
dkr�|} q�q�W|r�t|�dkr�t j
j|d�r�dGHtjd�q�nd}
y�|s�| rty| r�|| �}nWnt
k
r�d}
nX|
r}xk|D]`}t j
j|�rIt||||||�sjd}
qjq
t|||||�s
d}
q
q
Wq}n t�}
Wntk
r�dGHd}
nX|
S(sScript main program.i�Nis 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.tlenRRRRHR,RRRtKeyboardInterrupt(RItoptsRCR1RRRRRRDRtaRLRtarg((s /sys/lib/python2.7/compileall.pytmain�s�#
)
t__main__(t__doc__RR=R-R%R't__all__R
RRRRHRRt__name__R"texit_statusRK(((s /sys/lib/python2.7/compileall.pyt<module>s'4 J
|