Your IP : 216.73.216.213


Current Path : /opt/alt/python37/lib/python3.7/site-packages/pyflakes/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/pyflakes/__pycache__/api.cpython-37.pyc

B

:F�Vv�@s�dZddlmZddlZddlZddlZddlmZmZddlm	Z
dddd	d
gZddd�Zddd�Z
d
d	�Zdd�Zdd�Zddd
�ZdS)z,
API for the command-line I{pyflakes} tool.
�)�with_statementN)�checker�__version__)�reporter�check�	checkPath�checkRecursive�iterSourceCode�maincCsh|dkrt��}yt||dtj�}W�n�tk
�rt��d}|jd}|j	|j
|j}}}tj
r�|dkr�|��}	t|	�|kr�|	|d}tjdkr�t|t�r�y|�d�}Wntk
r�d}YnX|d8}|dkr�|�|d�n|�|||||�dStk
�r"|�|d�dSXt�||�}
|
jjdd	�d
�x|
jD]}|�|��qJWt|
j�S)a�
    Check the Python source given by C{codeString} for flakes.

    @param codeString: The Python source to check.
    @type codeString: C{str}

    @param filename: The name of the file the source came from, used to report
        errors.
    @type filename: C{str}

    @param reporter: A L{Reporter} instance, where errors and warnings will be
        reported.

    @return: The number of warnings emitted.
    @rtype: C{int}
    N�exec�r)��asciizproblem decoding sourcecSs|jS)N)�lineno)�m�r�=/opt/alt/python37/lib/python3.7/site-packages/pyflakes/api.py�<lambda>F�zcheck.<locals>.<lambda>)�key)�modReporter�_makeDefaultReporter�compile�_astZ
PyCF_ONLY_AST�SyntaxError�sys�exc_info�argsr�offset�textrZPYPY�
splitlines�len�version_info�
isinstance�bytes�decode�UnicodeDecodeError�unexpectedErrorZsyntaxError�	ExceptionZChecker�messages�sortZflake)Z
codeString�filenamerZtree�value�msgrrr�lines�wZwarningrrrrs>

c	Cs�|dkrt��}yHtjdkr"d}nd}t||��}|��}WdQRXtjdkrV|d7}WnPtk
rx|�|d�dStk
r�t�	�d}|�||j
d�dSXt|||�S)z�
    Check the given path, printing out any warnings detected.

    @param reporter: A L{Reporter} instance, where errors and warnings will be
        reported.

    @return: the number of warnings printed
    N)��ZrU�rb�
zproblem decoding sourcer)rrrr"�open�read�UnicodeErrorr'�IOErrorrrr)r+r�mode�fZcodestrr-rrrrLs$	

ccshxb|D]Z}tj�|�rZxHt�|�D]2\}}}x&|D]}|�d�r2tj�||�Vq2Wq"Wq|VqWdS)z�
    Iterate over all Python source files in C{paths}.

    @param paths: A list of paths.  Directories will be recursed into and
        any .py files found will be yielded.  Any non-directories will be
        yielded as-is.
    z.pyN)�os�path�isdir�walk�endswith�join)�pathsr;�dirpath�dirnames�	filenamesr+rrrr	os


cCs(d}xt|�D]}|t||�7}qW|S)a;
    Recursively check all source files in C{paths}.

    @param paths: A list of paths to Python source files and directories
        containing Python source files.
    @param reporter: A L{Reporter} where all of the warnings and errors
        will be reported to.
    @return: The number of warnings found.
    r)r	r)r@r�warningsZ
sourcePathrrrr�s
csbddl}yt||�}Wntk
r*dSX�fdd�}y|�||�Wntk
r\YnXdS)z�Handles a signal with sys.exit.

    Some of these signals (SIGPIPE, for example) don't exist or are invalid on
    Windows. So, ignore errors that might arise.
    rNcst���dS)N)r�exit)�sigr9)�messagerr�handler�sz_exitOnSignal.<locals>.handler)�signal�getattr�AttributeError�
ValueError)ZsigNamerGrIZ	sigNumberrHr)rGr�
_exitOnSignal�srMcCstddl}tdd�tdd�|j|td�}|j|d�\}}t��}|rRt||�}ntt	j
��d	|�}t|dk��dS)
z&Entry point for the script "pyflakes".rN�SIGINTz... stopped�SIGPIPEr)�prog�version)rz<stdin>)
�optparserM�OptionParserr�
parse_argsrrrrr�stdinr5�
SystemExit)rPrrR�parser�__rrDrrrr
�s

)N)N)NN)�__doc__�
__future__rrr:r�pyflakesrrrr�__all__rrr	rrMr
rrrr�<module>s
<
#