Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib/python3.5/site-packages/pyflakes/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib/python3.5/site-packages/pyflakes/__pycache__/api.cpython-35.opt-1.pyc



:F�Vv�@s�dZddlmZddlZddlZddlZddlmZmZddlm	Z
dddd	d
gZddd�Zddd�Z
d
d	�Zdd�Zdd�Zdddd
�ZdS)z,
API for the command-line I{pyflakes} tool.
�)�with_statementN)�checker�__version__)�reporter�check�	checkPath�checkRecursive�iterSourceCode�maincCs�|dkrtj�}yt||dtj�}WnDtk
rUtj�d}|jd}|j	|j
|j}}}tj
r|dkr|j�}	t|	�|kr|	|d}tjdkrt|t�ry|jd�}Wntk
r
d}YnX|d8}|dkr4|j|d�n|j|||||�dSYn&tk
rz|j|d�dSYnXtj||�}
|
jjdd	d
��x|
jD]}|j|�q�Wt|
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 source�keycSs|jS)N)�lineno)�m�r�=/opt/alt/python35/lib/python3.5/site-packages/pyflakes/api.py�<lambda>Fszcheck.<locals>.<lambda>)r
)�modReporter�_makeDefaultReporter�compile�_astZ
PyCF_ONLY_AST�SyntaxError�sys�exc_info�argsr�offset�textrZPYPY�
splitlines�len�version_info�
isinstance�bytes�decode�UnicodeDecodeError�unexpectedErrorZsyntaxError�	ExceptionZCheckerZmessages�sortZflake)Z
codeString�filenamerZtree�value�msgrrr�lines�wZwarningrrrrs>

	


	cCs�|dkrtj�}y`tjd	kr3d}nd}t||��}|j�}WdQRXtjd
krw|d7}Wnbtk
r�|j|d�dSYn=tk
r�tj	�d}|j||j
d�dSYnXt|||�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)r.r/)r.r/)rrrr!�open�read�UnicodeErrorr&�IOErrorrrr)r)r�mode�fZcodestrr+rrrrLs$		

	ccs�x|D]w}tjj|�ryx\tj|�D]C\}}}x1|D])}|jd�rEtjj||�VqEWq/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)�pathsr9�dirpathZdirnames�	filenamesr)rrrr	os

cCs4d}x't|�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
cswddl}yt||�}Wntk
r7dSYnX�fdd�}y|j||�Wntk
rrYnXdS)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.
    rNcstj��dS)N)r�exit)Zsigr7)�messagerr�handler�sz_exitOnSignal.<locals>.handler)�signal�getattr�AttributeError�
ValueError)ZsigNamerCrEZ	sigNumberrDr)rCr�
_exitOnSignal�s
	
rIcCs�ddl}tdd�tdd�|jd|dt�}|jd	|�\}}tj�}|rzt||�}ntt	j
j�d
|�}t|dk��dS)z&Entry point for the script "pyflakes".rN�SIGINTz... stopped�SIGPIPEr�prog�versionrz<stdin>)
�optparserIZOptionParserr�
parse_argsrrrrr�stdinr3�
SystemExit)rLrrN�parser�__rrArrrr
�s

)�__doc__Z
__future__rrr8rZpyflakesrrrr�__all__rrr	rrIr
rrrr�<module>s<#