B
    Áì2aÜ5  ã            	   @   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„ Zddd„Zddd„Zdd„ Zedkr˜eeƒ  ƒZe 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 | ¡} |s0td | ¡ƒ yt | ¡}W n. tk
rl   |dk rdtd | ¡ƒ g }Y nX | ¡  x¦|D ]ž}|dkrŠq|tj	 
| |¡}|d k	r°tj	 
||¡}nd }tj	 |¡sÌ||fV  q||dkr||tjkr||tjkr|tj	 |¡r|tj	 |¡s|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"   ú6/var/www/html/prediksi/Python-3.7.12/Lib/compileall.pyr      s0    


r   Féÿÿÿÿr	   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}| 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
    invalidation_mode: how the up-to-dateness of the pyc will be checked
    Nr   z%workers must be greater or equal to 0r	   )ÚProcessPoolExecutor)r   r   r
   T)Zmax_workers)ÚforceÚrxr   ÚlegacyÚoptimizeÚinvalidation_mode)ÚdefaultF)
Ú
ValueErrorZconcurrent.futuresr%   ÚImportErrorr   Úmapr   Ú_compile_file_tupleÚminr   )r   r   r
   r&   r'   r   r(   r)   Úworkersr*   r%   Zfiles_and_ddirsÚsuccessZexecutorÚresultsÚfiler!   r"   r"   r#   r   2   s6    


c             K   s   | \}}t ||f|ŽS )z-Needs to be toplevel for ProcessPoolExecutor.)r   )Zfile_and_dfileÚkwargsr4   r!   r"   r"   r#   r/   e   s    r/   c          
   C   sŽ  d}|dk r"t | tjƒr"t | ¡} tj | ¡}	|dk	rFtj ||	¡}
nd}
|dk	rd| | ¡}|rd|S tj | ¡�rŠ|r€| d }nB|dkrª|dkr”|nd}t	j
j| |d�}nt	j
 | ¡}tj |¡}|	dd	… |	d	d…  }}|d
k�rŠ|�sZyVtt | ¡jƒ}t dt	j
jd|¡}t|dƒ�}| d¡}W dQ R X ||k�r@|S W n tk
�rX   Y nX |�sntd | ¡ƒ ytj| ||
d||d�}W nò tjk
�r } zbd}|dk�r°|S |�rÆtd | ¡ƒ ntddd� |jjtjjdd�}|  tjj¡}t|ƒ W dd}~X Y n~ t!t"tfk
�rz } zJd}|dk�r6|S |�rLtd | ¡ƒ ntddd� t|j#j$d |ƒ W dd}~X Y nX |dk�rŠd}|S )aT  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
    invalidation_mode: how the up-to-dateness of the pyc will be checked
    Tr   NÚcr   r	   Ú )Úoptimizationéýÿÿÿz.pyz<4sllÚrbé   zCompiling {!r}...)r)   r*   Fz*** Error compiling {!r}...z*** )ÚendÚbackslashreplace)Úerrorsú:)%r   r   r   r   r   Úbasenamer   ÚsearchÚisfileÚ	importlibÚutilÚcache_from_sourceÚdirnameÚintÚstatÚst_mtimeÚstructÚ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*   r2   r   r!   ÚmoÚcfileÚoptÚ	cache_dirÚheadÚtailÚmtimeZexpectZchandleÚactualÚokÚerrrR   Úer"   r"   r#   r   j   sz    






$
c       	      C   sX   d}xNt jD ]D}|r|tjkr4| r4|dk rPtdƒ q|oNt||d|||||d�}qW |S )a¤  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)
    invalidation_mode: as for compiler_dir()
    Tr   zSkipping current directoryN)r   r(   r)   r*   )rT   r   r   r   r   r   )	Zskip_curdirr   r&   r   r(   r)   r*   r2   r   r"   r"   r#   r   À   s    
c              C   sÒ  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� d4d5„ tjD ƒ}|jd6t|ƒd7d8� | ¡ }|j}|j	�r$ddl
}| |j	¡|_	|jdk	�r8|j}n|j}|j�rÄyJ|jd9k�rZtjnt|jƒ�$}x|D ]}| | ¡ ¡ �qlW W dQ R X W n2 tk
�rÂ   |jd:k �r¾td; |j¡ƒ d<S X |jdk	�rÞ|j�pÚd|_|j�r|j d9d=¡ ¡ }	tj|	 }
nd}
d>}y–|�rŠxp|D ]h}tj |¡�rTt||j |j!|j	|j|j"|
d?��s€d<}n,t#|||j |j!|j	|j|j"|j|
d@�	�sd<}�qW |S t$|j"|j!|j|
dA�S W n* t%k
�rÌ   |jd:k �rÈtdBƒ d<S X d>S )CzScript main program.r   Nz1Utilities to support installing Python libraries.)Údescriptionz-lÚstore_constr   r   z!don't recurse into subdirectories)ÚactionÚconstr+   ÚdestÚhelpz-rÚ	recursionzhcontrol the maximum recursion level. if `-l` and `-r` options are specified, then `-r` takes precedence.)Útyperk   rl   z-fÚ
store_truer&   z/force rebuild even if timestamps are up to date)ri   rk   rl   z-qÚcountr   zIoutput only error messages; -qq will suppress the error messages as well.)ri   rk   r+   rl   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)Úmetavarrk   r+   rl   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)rq   rk   rl   Ú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)rq   Únargsrl   z-jz	--workersr	   zRun compileall concurrently)r+   rn   rl   c             S   s   g | ]}|j  ¡  d d¡‘qS )Ú_ú-)r   ÚlowerÚreplace)Ú.0Úmoder"   r"   r#   ú
<listcomp>	  s   zmain.<locals>.<listcomp>z--invalidation-modez‡set .pyc invalidation mode; defaults to "checked-hash" if the SOURCE_DATE_EPOCH environment variable is set, and "timestamp" otherwise.)Úchoicesrl   rw   r   zError reading file list {}Frv   T)r*   )r1   r*   )r(   r&   r   r*   z
[interrupted])&ÚargparseÚArgumentParserÚadd_argumentrG   rO   ZPycInvalidationModeÚsortedÚ
parse_argsrs   r'   ÚrerP   rm   r   rr   rT   ÚstdinrM   ÚappendÚstripr   r   r   r   r1   r*   ry   Úupperr   r   rB   r   r
   r&   r(   r   r   ÚKeyboardInterrupt)r~   ÚparserZinvalidation_modesÚargsZcompile_destsrƒ   r   ÚfÚlineZivl_moder*   r2   rk   r"   r"   r#   Úmainâ   s–    









"





r�   Ú__main__)Nr   r   )	r   NFNr   Fr$   r	   N)NFNr   Fr$   N)r	   r   Fr   Fr$   N)Ú__doc__r   rT   Úimportlib.utilrC   rO   rJ   Ú	functoolsr   Ú__all__r   r   r/   r   r   r�   r[   rG   Úexit_statusÚexitr"   r"   r"   r#   Ú<module>   s,   

  
1  
T  
 l