HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib64/python3.10/site-packages/pyflakes/__pycache__/api.cpython-310.pyc
o

we��@s�dZddlZddlZddlZddlZddlZddlmZmZddlm	Z
gd�Ze�d�Z
ddd�Zdd	d
�Zdd�Zd
d�Zdd�Zdd�Zdd�Zddd�ZdS)z,
API for the command-line I{pyflakes} tool.
�N)�checker�__version__)�reporter)�check�	checkPath�checkRecursive�iterSourceCode�mains#^#!.*\bpython(3(\.\d+)?|w)?[dmu]?\sc
Cs�|durt��}z	tj||d�}Wn1ty3}z|�||jd|j|j|j	�WYd}~dSd}~wt
yB|�|d�YdSwtj
||d�}|jjdd�d�|jD]}|�|�qVt|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)�filenamer�zproblem decoding sourcecSs|jS�N)�lineno)�m�r�E/home/arjun/projects/env/lib/python3.10/site-packages/pyflakes/api.py�<lambda>0szcheck.<locals>.<lambda>)�key)�modReporter�_makeDefaultReporter�ast�parse�SyntaxError�syntaxError�argsr
�offset�text�	Exception�unexpectedErrorr�Checker�messages�sort�flake�len)�
codeStringr
r�tree�e�w�warningrrrrs"��

rc
Cs�|durt��}zt|d��}|��}Wd�n1swYWnty?}z|�||jd�WYd}~dSd}~wwt|||�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�rbr)rr�open�read�OSErrorrrr)r
r�f�codestrr%rrrr6s	
����rcCs�|�d�rdS|�d�rdSd}z(t|d��}|�|�}|s(	Wd�WdSWd�n1s2wYWn
tyBYdSwt�|�S)z0Return True if filename points to a Python file.z.pyT�~F�r(N)�endswithr)r*r+�PYTHON_SHEBANG_REGEX�match)r
�	max_bytesr,rrrr�isPythonFileJs$


����
r4ccs`�|D]*}tj�|�r*t�|�D]\}}}|D]}tj�||�}t|�r'|Vqqq|VqdS)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.
    N)�os�path�isdir�walk�joinr4)�pathsr6�dirpath�dirnames�	filenamesr
�	full_pathrrrr`s�����rcCs$d}t|�D]	}|t||�7}q|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)rr)r:r�warnings�
sourcePathrrrrss
rcs`ddl}zt||�}Wn
tyYdSw�fdd�}z	|�||�WdSty/YdSw)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���dSr)�sys�exit)�sigr,��messagerr�handler�sz_exitOnSignal.<locals>.handler)�signal�getattr�AttributeError�
ValueError)�sigNamerErG�	sigNumberrFrrDr�
_exitOnSignal�s��rMcCsdtt��t��fS)zQ
    Retrieve and format package version along with python version & OS used
    z%s Python %s on %s)r�platform�python_version�systemrrrr�_get_version�s�rQcCs�ddl}tdd�tdd�|j|dd�}|jd	d
dt�d�|jd
ddd�|j|d�j}t��}|r:t	||�}n	t
tj�
�d|�}t|dk��)z&Entry point for the script "pyflakes".rN�SIGINTz... stopped�SIGPIPErz$Check Python source files for errors)�prog�descriptionz-Vz	--version�version)�actionrVr6�*z7Path(s) of Python file(s) to check. STDIN if not given.)�nargs�help)rz<stdin>)�argparserM�ArgumentParser�add_argumentrQ�
parse_argsr6rrrrrA�stdinr*�
SystemExit)rTrr[�parserrr?rrrr	�s 

��r	r)NN)�__doc__rr5rN�rerA�pyflakesrrrr�__all__�compiler1rrr4rrrMrQr	rrrr�<module>s$


$