Pc@sdZddlZddlZddlZddlZddlZdddgZddddddZddddd Z d dddd Z d Z d Z e dkree ZejendS(sModule/script to "compile" all .py files to .pyc (or .pyo) file. 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: if given, purported directory name (this is the directory name that will show up in error messages) 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..\python\lib\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(s=Byte-compile file. file: the file to byte-compile ddir: if given, purported directory name (this is the directory name that will show up in error messages) 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..\python\lib\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..\python\lib\compileall.pyRrs 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..\python\lib\compileall.pyt expand_argss       c Csddl}y#|jtjdd\}}WnU|jk r}|GHdGHdGHdGHdGHd GHd GHd GHd GHd GHtjdnXd}d}d}d}d}d} x|D]\} } | dkrd}n| dkr| }n| dkrd}n| dkrd}n| dkr<ddl} | j| }n| dkr| } qqW|rt|dkrt j j |d rdGHtjdqnd} y|s| r^y| rt || }nWnt k rd} nX| rgxk|D]`}t j j |r3t||||||sTd} qTqt|||||sd} qqWqgn 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 ...]s-l: don't recurse downs3-f: force rebuild even if timestamps are up-to-dates-q: quiet operations7-d destdir: purported directory name for error messagess4 if no directory arguments, -l sys.path is assumeds<-x regexp: skip files matching the regular expression regexps: the regexp is searched for in the full path of the files@-i list: expand list with its content (file and directory names)ii is-ls-ds-fs-qs-xs-is1-d destdir require exactly one directory arguments [interrupt](tgetoptR=targvRtexitR treR.tlenRRR RHR,RRRtKeyboardInterrupt(RItoptsRCR1RRRRRRDRtaRLRtarg((s..\python\lib\compileall.pytmainsx #       )         t__main__(t__doc__RR=R-R%R't__all__R RRRRHRRt__name__R"t exit_statusRK(((s..\python\lib\compileall.pyt s     (3  =