Your IP : 216.73.216.85


Current Path : /opt/alt/python37/lib64/python3.7/Tools/scripts/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/Tools/scripts/__pycache__/pysource.cpython-37.pyc

B

� f$�@s�dZdZddddgZddlZddlZe�d�Zd	Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zedfdd�Z
edkr�xe
dg�D]Zee�q|Wed�xe
dged�D]Zee�q�WdS)aCList python source files.

There are three functions to check whether a file is a Python source, listed
here with increasing complexity:

- has_python_ext() checks whether a file name ends in '.py[w]'.
- look_like_python() checks whether the file is not binary and either has
  the '.py[w]' extension or the first line contains the word 'python'.
- can_be_compiled() checks whether the file can be compiled by compile().

The file also must be of appropriate size - not bigger than a megabyte.

walk_python_files() recursively lists all Python files under the given directories.
zOleg Broytmann, Georg Brandl�has_python_ext�looks_like_python�can_be_compiled�walk_python_files�Ns[\x00-\x08\x0E-\x1F\x7F]FcCstrt|�dS)N)�debug�print)�msg�r	�;/opt/alt/python37/lib64/python3.7/Tools/scripts/pysource.py�print_debugsrc
Cs�yt�|�j}Wn2tk
rB}ztd||f�dSd}~XYnX|dkr`td||f�dSy
t|d�Stk
r�}ztd||f�dSd}~XYnXdS)Nz%s: permission denied: %siz!%s: the file is too big: %d bytes�rbz%s: access denied: %s)�os�stat�st_size�OSErrorr�open�IOError)�fullpath�size�errr	r	r
�_open!s
rcCs|�d�p|�d�S)Nz.pyz.pyw)�endswith)rr	r	r
r2sc	Csnt|�}|dkrdS|�|��}WdQRXt�|�rFtd|�dS|�d�sZ|�d�r^dSd|krjdSdS)NFz%s: appears to be binaryz.pyz.pywTspython)r�readline�	binary_re�searchrr)r�infile�liner	r	r
r5s
c
Cstt|�}|dkrdS|�|��}WdQRXyt||d�Wn2tk
rn}ztd||f�dSd}~XYnXdS)NF�execz%s: cannot compile: %sT)r�read�compile�	Exceptionr)rr�coderr	r	r
rJsc
cs�|dkrg}x�|D]�}td|�tj�|�r>||�r�|Vqtj�|�r�td�xxt�|�D]`\}}}x|D]}||krn|�|�qnWx4|D],}tj�||�}	td|	�||	�r�|	Vq�Wq^Wqtd�qWdS)a^    Recursively yield all Python source files below the given paths.

    paths: a list of files and/or directories to be checked.
    is_python: a function that takes a file name and checks whether it is a
               Python source file
    exclude_dirs: a list of directory base names that should be excluded in
                  the search
    Nztesting: %sz    it is a directoryz    unknown type)rr
�path�isfile�isdir�walk�remove�join)
�paths�	is_pythonZexclude_dirsr"�dirpathZdirnames�	filenamesZexclude�filenamerr	r	r
r[s&



�__main__�.z
----------)r))�__doc__�
__author__�__all__r
�rerrrrrrrrr�__name__rrr	r	r	r
�<module>s"
!