3 \]/ � @ s� d Z ddlZddlZddlZddlZddlZddlmZ dddgZ ddd �Z ddd�Zdd d�Zddd�Z dd� Zedkr�ee� �Zeje� dS )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 |dk rt | tj�rtj| �} |s0tdj| �� ytj| �}W n. tk rl |dk rdtdj| �� g }Y nX |j� x�|D ]�}|dkr�q|tj j | |�}|d k r�tj j ||�}nd }tj j|�s�|V q||dkr||tjkr||tj kr|tj j|�r|tj j|� r|t|||d |d�E d H q|W d S )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.6/compileall.pyr s0 r Fr c C s� d} |dk rP|dk rt d��n2|dkrPyddlm} W n tk rN d}Y nX t| |||d�} d}|dk r�|dkr�| dk r�|p�d}| |d��0}|jtt||||||d �| �} t| dd �}W dQ 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)Zmax_workers)r �force�rxr �legacy�optimize)�defaultF) � ValueErrorZconcurrent.futuresr$ �ImportErrorr �mapr r �min)r r r r% r&