Your IP : 216.73.216.213
�
e f$ � @ s d Z d Z d d d d g Z d d l Z d d l Z e j d � Z d Z d
d � Z d d
� Z d d � Z
d d � Z d d � Z e d d d � Z
e d k r x! e
d g � D] Z e e � q� We d � x* e
d g d e �D] Z e e � q� Wn d S)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 r t | � n d S)N)�debug�print)�msg� r �;/opt/alt/python34/lib64/python3.4/Tools/scripts/pysource.py�print_debug s r c C s� y t j | � j } Wn= t k
rU } z t d | | f � d SWYd d } ~ Xn X| d k rz t d | | f � d Sy t | d � SWn= t k
r� } z t d | | f � d SWYd d } ~ Xn Xd S)Nz%s: permission denied: %si z!%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 r c C s | j d � p | j d � S)Nz.pyz.pyw)�endswith)r r r r
r 2 s c C s� t | � } | d k r d S| � | j � } Wd QXt j | � rV t d | � d S| j d � st | j d � rx d Sd | k r� d Sd S)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 s� t | � } | d k r d S| � | j � } Wd QXy t | | d � Wn= t k
r� } z t d | | f � d SWYd d } ~ Xn Xd S)NF�execz%s: cannot compile: %sT)r �read�compile� Exceptionr )r r �coder r r r
r J s c
c s" | d k r g } n x| D]� } t d | � t j j | � rY | | � r| Vqq t j j | � rt d � x� t j | � D]� \ } } } x* | D]"