
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
3

  \]/  ã               @   s”   d Z ddlZddlZddlZddlZddlZddlmZ dddgZ	ddd	„Z
ddd„Zddd„Z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)ÚpartialÚcompile_dirÚcompile_fileÚcompile_pathé
   c             c   s   |dk rt | tjƒrtj| ƒ} |s0tdj| ƒƒ ytj| ƒ}W n. tk
rl   |dk rdtdj| ƒƒ g }Y nX |jƒ  x¤|D ]œ}|dkrŠq|tj	j
| |ƒ}|d k	r°tj	j
||ƒ}nd }tj	j|ƒsÈ|V  q||dkr||tjkr||tjkr|tj	j|ƒr|tj	j|ƒ r|t|||d |d�E d H  q|W d S )Né   zListing {!r}...zCan't list {!r}Ú__pycache__r   é   )ÚddirÚ	maxlevelsÚquiet)Ú
isinstanceÚosÚPathLikeÚfspathÚprintÚformatÚlistdirÚOSErrorÚsortÚpathÚjoinÚisdirÚcurdirÚpardirÚislinkÚ	_walk_dir)Údirr
   r   r   ÚnamesÚnameÚfullnameÚdfile© r"   ú"/usr/lib64/python3.6/compileall.pyr      s0    


r   Fr	   c	             C   sð   d}	|dk	rP|dk rt dƒ‚n2|dkrPyddlm}	 W n tk
rN   d}Y nX t| |||d�}
d}|dk	rÆ|dkrÆ|	dk	rÆ|p‚d}|	|d��0}|jtt||||||d	�|
ƒ}t|dd
�}W dQ R X n&x$|
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	   )ÚProcessPoolExecutor)r   r   r
   T)Zmax_workers)r
   ÚforceÚrxr   ÚlegacyÚoptimize)ÚdefaultF)	Ú
ValueErrorZconcurrent.futuresr$   ÚImportErrorr   Úmapr   r   Úmin)r   r   r
   r%   r&   r   r'   r(   Úworkersr$   ÚfilesÚsuccessZexecutorZresultsÚfiler"   r"   r#   r   2   s6    


c             C   sŠ  d}|dk r"t | tjƒr"tj| ƒ} tjj| ƒ}|dk	rFtjj||ƒ}	nd}	|dk	rd|j| ƒ}
|
rd|S tjj| ƒ�r†|r€| d }nB|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†|�sXyTttj| ƒjƒ}tjdt	j
j|ƒ}t|dƒ�}|jdƒ}W dQ R X ||k�r>|S W n tk
�rV   Y nX |�sltdj| ƒƒ ytj| ||	d|d�}W nò tjk
�r } zdd}|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|ƒ W Y dd}~X n~ t!t"tfk
�rv } zLd}|dk�r2|S |�rHtdj| ƒƒ ntddd� t|j#j$d |ƒ W Y dd}~X n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
    Tr   NÚcr   r	   Ú )Úoptimizationé   z.pyz<4slÚrbé   zCompiling {!r}...)r(   Fz*** Error compiling {!r}...z*** )ÚendÚbackslashreplace)Úerrorsú:éýÿÿÿr<   )%r   r   r   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(   r0   r   r!   ZmoÚcfileÚoptZ	cache_dirÚheadÚtailÚmtimeZexpectZchandleZactualÚokÚerrrN   Úer"   r"   r#   r   b   sx    






$
c          
   C   sX   d}xNt jD ]D}| s |tjkr6| r6|dk rPtdƒ q|oNt||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)
    Tr   zSkipping current directoryN)r   r'   r(   )rP   r   r   r   r   r   )Zskip_curdirr   r%   r   r'   r(   r0   r   r"   r"   r#   r   µ   s    
c        
      C   sz  ddl } | jdd�}|jdddddd	d
� |jdtddd� |jddddd� |jdddddd� |jddddd� |jdddddd � |jd!d"d#dd$d � |jd%d&d'd(d)� |jd*d+d,d-d.� |jd/d0d1td2d3� |jƒ }|j}|jrþddl}|j|jƒ|_|j	dk	�r|j	}n|j
}|j�ržyJ|jd4k�r4tjnt|jƒ�$}x|D ]}|j|jƒ ƒ �qFW W dQ R X W n2 tk
�rœ   |jd5k �r˜td6j|jƒƒ d7S X |jdk	�r¸|j�p´d|_d8}yŽ|�r4xj|D ]b}	tjj|	ƒ�r t|	|j|j|j|j|jƒ�s*d7}n*t|	||j|j|j|j|j|jd9��sÊd7}�qÊW |S t|j|j|jd:�S W n* tk
�rt   |jd5k �rptd;ƒ d7S X d8S )<zScript main program.r   Nz1Utilities to support installing Python libraries.)Zdescriptionz-lZstore_constr   r   z!don't recurse into subdirectories)ÚactionZconstr)   ÚdestÚhelpz-rÚ	recursionzhcontrol the maximum recursion level. if `-l` and `-r` options are specified, then `-r` takes precedence.)Útypera   rb   z-fÚ
store_truer%   z/force rebuild even if timestamps are up to date)r`   ra   rb   z-qÚcountr   zIoutput only error messages; -qq will suppress the error messages as well.)r`   ra   r)   rb   z-br'   z0use legacy (pre-PEP3147) compiled file locationsz-dZDESTDIRr
   z�directory to prepend to file paths for use in compile-time tracebacks and in runtime tracebacks in cases where the source file is unavailable)Úmetavarra   r)   rb   z-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)rg   ra   rb   Úcompile_destzFILE|DIRÚ*zrzero or more file and directory names to compile; if no arguments given, defaults to the equivalent of -l sys.path)rg   Únargsrb   z-jz	--workersr	   zRun compileall concurrently)r)   rd   rb   ú-r   zError reading file list {}FT)r.   )r'   r%   r   z
[interrupted]) ÚargparseÚArgumentParserÚadd_argumentrD   Ú
parse_argsri   r&   ÚrerL   rc   r   rh   rP   ÚstdinrI   ÚappendÚstripr   r   r   r   r.   r   r   r?   r   r
   r%   r'   r   r   ÚKeyboardInterrupt)
rm   ÚparserÚargsZcompile_destsrq   r   ÚfÚliner0   ra   r"   r"   r#   ÚmainÎ   s~    








"



rz   Ú__main__)Nr   r   éÿÿÿÿ)r   NFNr   Fr|   r	   r|   )NFNr   Fr|   r|   )r	   r   Fr   Fr|   )Ú__doc__r   rP   Úimportlib.utilr@   rK   rG   Ú	functoolsr   Ú__all__r   r   r   r   rz   rW   rD   Zexit_statusÚexitr"   r"   r"   r#   Ú<module>   s$   

 
/ 
R 
[