U e5dn5� @s�ddlZddlZddlZddlZddlZddlmZdddgZddd�Z dd d�Z d d�Z ddd�Z ddd�Z dd�Zedkr�ee� �Ze�e�dS)�N)�partial� compile_dir� compile_file� compile_path� ccs|dkrt|tj�rt�|�}|s0td�|��zt�|�}Wn.tk rl|dkrdtd�|��g}YnX|��|D]�}|dkr�qztj � ||�}|dk r�tj � ||�}nd}tj � |�s�||fVqz|dkrz|tj krz|tj krztj � |�rztj �|�szt|||d|d�EdHqzdS)N�zListing {!r}...zCan'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.8/compileall.pyrs:     � ��rF�����r c  Cs�d} |dkrtd��|dkrFzddlm} Wntk rDd}YnXt||||d�} d} |dkr�| dk r�|ppd}| |d��0} | �tt|||||| d�| �}t|dd �} W5QRXn(| D]"\}}t |||||||| �s�d } q�| S) Nrz%workers must be greater or equal to 0r )�ProcessPoolExecutor)r r r T)Z max_workers)�force�rxr �legacy�optimize�invalidation_mode)�defaultF) � ValueErrorZconcurrent.futuresr%� ImportErrorr�mapr�_compile_file_tuple�minr)rr r r&r'r r(r)�workersr*r%Zfiles_and_ddirs�successZexecutorZresults�filer!r"r"r#r2sF � ��  �cKs|\}}t||f|�S)N)r)Zfile_and_dfile�kwargsr3r!r"r"r#r/esr/c Cs�d}|dkr"t|tj�r"t�|�}tj�|�} |dk rFtj�|| �} nd} |dk rd|�|�} | rd|Stj�|��r�|r�|d} nB|dkr�|dkr�|nd} t j j || d�} n t j � |�} tj� | �}| dd�| dd�}}|d k�r�|�s\zXt t�|�j�}t�d t j jd|�}t| d ��}|�d �}W5QRX||k�rB|WSWntk �rZYnX|�sptd �|��ztj|| | d||d�}W�ntjk �r}zjd}|dk�r�|WY�RS|�r�td�|��n tddd�|jjtjjdd�}|� tjj�}t|�W5d}~XYn�t!t"tfk �r�}zRd}|dk�rJ|WY�:S|�r`td�|��n tddd�t|j#j$d|�W5d}~XYnX|dk�r�d}|S)NTr�crr �)� optimization�����z.pyz<4sll�rb� zCompiling {!r}...)r)r*Fz*** Error compiling {!r}...z*** )�end�backslashreplace)�errors�:)%r rrrr�basenamer�search�isfile� importlib�util�cache_from_source�dirname�int�stat�st_mtime�structZpack� MAGIC_NUMBER�open�readrrr� py_compile�compile�PyCompileError�msg�encode�sys�stdout�encoding�decode� SyntaxError� UnicodeError� __class__�__name__)r r r&r'r r(r)r*r2rr!Zmo�cfile�optZ cache_dir�head�tail�mtimeZexpectZchandleZactual�ok�errrP�er"r"r#rjs�    �    �    �     �   $ c CsTd}tjD]D}|r|tjkr2|r2|dkrNtd�q |oLt||d|||||d�}q |S)NTrzSkipping current directory)r r(r)r*)rRrrrrr) Z skip_curdirr r&r r(r)r*r2rr"r"r#r�s   � c Cs�ddl}|jdd�}|jddddddd �|jd td d d �|jddddd�|jdddddd�|jddddd�|jdddddd�|jd d!d"dd#d�|jd$d%d&d'd(�|jd)d*d+d,d-�|jd.d/d0td1d2�d3d4�tjD�}|jd5t|�d6d7�|��}|j}|j �r$ddl }|� |j �|_ |j dk �r8|j }n|j }|j�r�zF|jd8k�rZtjnt|j�� }|D]}|�|����qjW5QRXWn4tk �r�|jd9k�r�td:�|j��Yd;SX|j�r�|j�d8d<���} tj| } nd} d=} z�|�rl|D]h} tj�| ��r6t| |j|j |j |j|j!| d>��sbd;} n,t"| ||j|j |j |j|j!|j#| d?� �s�d;} �q�| WSt$|j!|j |j| d@�WSWn,t%k �r�|jd9k�r�tdA�Yd;SXd=S)BNrz1Utilities to support installing Python libraries.)Z descriptionz-lZ store_constrr z!don't recurse into subdirectories)�actionZconstr+�dest�helpz-r� recursionzhcontrol the maximum recursion level. if `-l` and `-r` options are specified, then `-r` takes precedence.)�typercrdz-f� store_truer&z/force rebuild even if timestamps are up to date)rbrcrdz-q�countr zIoutput only error messages; -qq will suppress the error messages as well.)rbrcr+rdz-br(z0use legacy (pre-PEP3147) compiled file locationsz-dZDESTDIRr 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)�metavarrcr+rdz-xZREGEXPr'zskip files matching the regular expression; the regexp is searched for in the full path of each file considered for compilationz-iZFILE�flistzzadd all the files and directories listed in FILE to the list considered for compilation; if "-", names are read from stdin)rircrd� compile_destzFILE|DIR�*zrzero or more file and directory names to compile; if no arguments given, defaults to the equivalent of -l sys.path)ri�nargsrdz-jz --workersr zRun compileall concurrently)r+rfrdcSsg|]}|j���dd��qS)�_�-)r�lower�replace)�.0�moder"r"r#� s�zmain..z--invalidation-modez�set .pyc invalidation mode; defaults to "checked-hash" if the SOURCE_DATE_EPOCH environment variable is set, and "timestamp" otherwise.)�choicesrdrorzError reading file list {}FrnT)r*)r1r*)r(r&r r*z [interrupted])&�argparse�ArgumentParser� add_argumentrFrM�PycInvalidationMode�sorted� parse_argsrkr'�rerNrer rjrR�stdinrK�append�striprr rrr*rq�upperrrrArr r&r(rr1r�KeyboardInterrupt) rv�parserZinvalidation_modes�argsZ compile_destsr|r �f�lineZivl_moder*r2rcr"r"r#�main�s�� � � � � � � � � � ���    � � �  r��__main__)Nrr) rNFNrFr$r N)NFNrFr$N)r rFrFr$N)rrR�importlib.utilrBrMrI� functoolsr�__all__rrr/rrr�rYrFZ exit_status�exitr"r"r"r#� s:   � 3� V� "i