Your IP : 216.73.216.213


Current Path : /opt/alt/python34/lib64/python3.4/Tools/scripts/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/Tools/scripts/__pycache__/pysource.cpython-34.pyo

�
e f$�@sdZdZddddgZddlZddlZejd�Zd	Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zeddd�Z
edkrx!e
dg�D]Zee�q�Wed�x*e
dgde�D]Zee�q�WndS)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]FcCstrt|�ndS)N)�debug�print)�msg�r	�;/opt/alt/python34/lib64/python3.4/Tools/scripts/pysource.py�print_debugsrcCs�ytj|�j}Wn=tk
rU}ztd||f�dSWYdd}~XnX|dkrztd||f�dSyt|d�SWn=tk
r�}ztd||f�dSWYdd}~XnXdS)Nz%s: permission denied: %siz!%s: the file is too big: %d bytes�rbz%s: access denied: %si)�os�stat�st_size�OSErrorr�open�IOError)�fullpath�size�errr	r	r
�_open!srcCs|jd�p|jd�S)Nz.pyz.pyw)�endswith)rr	r	r
r2sc	Cs�t|�}|dkrdS|�|j�}WdQXtj|�rVtd|�dS|jd�st|jd�rxdSd|kr�dSdS)NFz%s: appears to be binaryz.pyz.pywTspython)r�readline�	binary_re�searchrr)r�infile�liner	r	r
r5scCs�t|�}|dkrdS|�|j�}WdQXyt||d�Wn=tk
r�}ztd||f�dSWYdd}~XnXdS)NF�execz%s: cannot compile: %sT)r�read�compile�	Exceptionr)rr�coderr	r	r
rJsc
cs"|dkrg}nx|D]�}td|�tjj|�rY||�r|Vqqtjj|�rtd�x�tj|�D]�\}}}x*|D]"}||kr�|j|�q�q�WxE|D]=}tjj||�}	td|	�||	�r�|	Vq�q�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"!