Your IP : 216.73.216.85
B
� f$ � @ s� d Z dZddddgZddlZddlZe�d�Zd Zd
d� Zdd
� Z dd� Z
dd� Zdd� Zedfdd�Z
edkr�xe
dg�D ]Zee� q|W ed� xe
dged�D ]Zee� q�W dS )aC List 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]Fc C s t rt| � d S )N)�debug�print)�msg� r �;/opt/alt/python37/lib64/python3.7/Tools/scripts/pysource.py�print_debug s r c
C s� yt �| �j}W n2 tk
rB } ztd| |f � d S d }~X Y nX |dkr`td| |f � d S y
t| d�S tk
r� } ztd| |f � d S d }~X Y nX d S )Nz%s: permission denied: %si z!%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
r c C s | � d�p| � d�S )Nz.pyz.pyw)�endswith)r r r r
r 2 s c C sn t | �}|d krdS |� |�� }W d Q R X t�|�rFtd| � dS | �d�sZ| �d�r^dS d|krjdS dS )NFz%s: appears to be binaryz.pyz.pywTs python)r �readline� binary_re�searchr r )r �infile�liner r r
r 5 s
c
C st t | �}|d krdS |� |�� }W d Q R X yt|| d� W n2 tk
rn } ztd| |f � dS d }~X Y nX dS )NF�execz%s: cannot compile: %sT)r �read�compile� Exceptionr )r r �coder r r r
r J s c
c s� |dkrg }x�| D ]�}t d| � tj�|�r>||�r�|V qtj�|�r�t d� xxt�|�D ]`\}}}x|D ]}||krn|�|� qnW x4|D ],}tj�||�} t d| � || �r�| V q�W q^W qt d� qW dS )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)r r
�path�isfile�isdir�walk�remove�join)
�paths� is_pythonZexclude_dirsr"