???<!-- GIF89;a -->
123123123123
.....................................................................................................................................???<!-- GIF89;a -->
123123123123
.....................................................................................................................................
Yf-                 @   s>  d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z y d d l m Z Wn e	 k
 rp d Z Yn Xd d l
 m Z d d d g Z d d d d	 d
  Z d d d d d d d d d d  Z d d d d d d d d  Z d d d d d d d d  Z d d   Z e d k r:e e    Z e j e  d S)a  Module/script to byte-compile all .py files to .pyc 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.
    N)ProcessPoolExecutor)partialcompile_dircompile_filecompile_path
   c             c   sa  | s t  d j |    y t j |   } Wn7 t k
 re | d k  r[ t  d j |    g  } Yn X| j   x | D] } | d k r qw t j j |  |  } | d  k	 r t j j | |  } n d  } t j j |  s | Vqw | d k rw | t j	 k rw | t j
 k rw t j j |  rw t j j |  rw t | d | d | d d	 | Ed  Hqw Wd  S)
NzListing {!r}...   zCan't list {!r}__pycache__r   ddir	maxlevels   quiet)printformatoslistdirOSErrorsortpathjoinisdircurdirpardirislink	_walk_dir)dirr
   r   r   namesnamefullnamedfile r    //opt/alt/python35/lib64/python3.5/compileall.pyr      s,    
*%r   Fr   c	             C   s  | d k	 r$ | d k  r$ t  d   t |  d | d | d | }	 d }
 | d k	 r | d k r t d k	 r | pu d } t d |  U } | j t t d | d	 | d
 | d | d | d | |	  } t | d d }
 Wd QRXn5 x2 |	 D]* } t | | | | | | |  s d }
 q W|
 S)a  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 True, force compilation, even if timestamps are up-to-date
    quiet:     full output with False or 0, errors only with 1,
               no output with 2
    legacy:    if True, produce legacy pyc paths instead of PEP 3147 paths
    optimize:  optimization level or -1 for level of the interpreter
    workers:   maximum number of parallel workers
    Nr   z%workers must be greater or equal to 0r   r   r
   r   Zmax_workersforcerxlegacyoptimizedefault)
ValueErrorr   r   mapr   r   min)r   r   r
   r"   r#   r   r$   r%   workersfilessuccessZexecutorZresultsfiler    r    r!   r   4   s(    	$	
c             C   s'  d } t  j j |   } | d k	 r< t  j j | |  }	 n d }	 | d k	 rg | j |   }
 |
 rg | St  j j |   r#| r |  d } nc | d k r | d k r | n d } t j j |  d | } n t j j |   } t  j j	 |  } | d d  | d d  } } | d k r#| syo t
 t  j |   j  } t j d	 t j j |  } t | d
   } | j d  } Wd QRX| | k r| SWn t k
 rYn X| st d j |    y" t j |  | |	 d d | } Wn-t j k
 r} z d } | d k r| S| r+t d j |    n t d d d | j j t j j d d } | j t j j  } t |  WYd d } ~ Xn t t t f k
 r} z^ d } | d k r| S| rt d j |    n t d d d t | j  j! d |  WYd d } ~ Xn X| d k r#d } | S)a  Byte-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 True, force compilation, even if timestamps are up-to-date
    quiet:     full output with False or 0, errors only with 1,
               no output with 2
    legacy:    if True, produce legacy pyc paths instead of PEP 3147 paths
    optimize:  optimization level or -1 for level of the interpreter
    r   Ncr    optimization   z.pyz<4slrb   zCompiling {!r}...Tr%   r   z*** Error compiling {!r}...z*** enderrorsbackslashreplace:r8   )"r   r   basenamer   searchisfile	importlibutilcache_from_sourcedirnameintstatst_mtimestructZpackMAGIC_NUMBERopenreadr   r   r   
py_compilecompilePyCompileErrormsgencodesysstdoutencodingdecodeSyntaxErrorUnicodeError	__class____name__)r   r
   r"   r#   r   r$   r%   r,   r   r   ZmocfileZoptZ	cache_dirheadtailmtimeZexpectZchandleZactualokerrrJ   er    r    r!   r   \   st    	!		*c             C   s   d } xs t  j D]h } | s, | t j k rK |  rK | d k  rx t d  q | ou t | | d | d | d | d | } q W| S)aw  Byte-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 False)
    quiet: as for compile_dir() (default 0)
    legacy: as for compile_dir() (default False)
    optimize: as for compile_dir() (default -1)
    r   r   zSkipping current directoryNr   r$   r%   )rL   r   r   r   r   r   )Zskip_curdirr   r"   r   r$   r%   r,   r   r    r    r!   r      s    c        
      C   s  d d l  }  |  j d d  } | j d d d d d d	 d
 d d d d | j d d t d d d d | j d d d d d d d | j d d d d d d	 d d d | j d d d d d d d | j d d d  d d! d	 d d d" | j d# d d$ d d% d	 d d d& | j d' d d( d d) d d* | j d+ d d, d- d. d d/ | j d0 d1 d	 d2 d t d d3 | j   } | j } | j rd d l } | j | j  | _ | j	 d k	 r| j	 } n	 | j
 } | j rxyY | j d4 k rt j n t | j  + } x! | D] } | j | j    qWWd QRXWn; t k
 rw| j d5 k  rot d6 j | j   d7 SYn X| j d k	 r| j pd | _ d8 } y | r>x | D] }	 t j j |	  rt |	 | j | j | j | j | j  s6d7 } qt |	 | | j | j | j | j | j d9 | j sd7 } qW| St d | j d | j d | j  SWn/ t k
 r| j d5 k  rt d:  d7 SYn Xd8 S);zScript main program.r   NZdescriptionz1Utilities to support installing Python libraries.z-lactionZstore_constZconstr&   r   destr   helpz!don't recurse into subdirectoriesz-rtype	recursionzhcontrol the maximum recursion level. if `-l` and `-r` options are specified, then `-r` takes precedence.z-f
store_truer"   z/force rebuild even if timestamps are up to datez-qcountr   zIoutput only error messages; -qq will suppress the error messages as well.z-br$   z0use legacy (pre-PEP3147) compiled file locationsz-dmetavarZDESTDIRr
   zdirectory to prepend to file paths for use in compile-time tracebacks and in runtime tracebacks in cases where the source file is unavailablez-xZREGEXPr#   zskip files matching the regular expression; the regexp is searched for in the full path of each file considered for compilationz-iZFILEflistzzadd all the files and directories listed in FILE to the list considered for compilation; if "-", names are read from stdincompile_destzFILE|DIRnargs*zrzero or more file and directory names to compile; if no arguments given, defaults to the equivalent of -l sys.pathz-jz	--workersr   zRun compileall concurrently-r   zError reading file list {}FTr*   z
[interrupted]) argparseArgumentParseradd_argumentr@   
parse_argsrd   r#   rerH   r_   r   rc   rL   stdinrE   appendstripr   r   r   r   r*   r   r   r;   r   r
   r"   r$   r   r   KeyboardInterrupt)
rh   parserargsZcompile_destsrl   r   fliner,   r\   r    r    r!   main   s~    						*"		

	ru   __main__rw   rw   )__doc__r   rL   importlib.utilr<   rG   rC   Zconcurrent.futuresr   ImportError	functoolsr   __all__r   r   r   r   ru   rS   r@   Zexit_statusexitr    r    r    r!   <module>   s,   'P[