
    yIf                         d Z ddlZddlZddlZddlZddlZddlmZmZ ddlm	Z
 g dZ ej        d          ZddZddZd	 Zd
 Zd Zd Zd ZddZdS )z,
API for the command-line I{pyflakes} tool.
    N)checker__version__)reporter)check	checkPathcheckRecursiveiterSourceCodemains#   ^#!.*\bpython(3(\.\d+)?|w)?[dmu]?\sc                     |t          j                    }	 t          j        | |          }nm# t          $ r>}|                    ||j        d         |j        |j        |j	                   Y d}~dS d}~wt          $ r |                    |d           Y dS w xY wt          j        ||          }|j                            d            |j        D ]}|                    |           t#          |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      zproblem decoding sourcec                     | j         S N)lineno)ms    @/var/www/piapp/venv/lib/python3.11/site-packages/pyflakes/api.py<lambda>zcheck.<locals>.<lambda>0   s    !(     )key)modReporter_makeDefaultReporterastparseSyntaxErrorsyntaxErrorargsr   offsettext	ExceptionunexpectedErrorr   Checkermessagessortflakelen)
codeStringr   r   treeewwarnings          r   r   r      s   " 355yh777   Xqvay!(AHafMMMqqqqq     +DEEEqq 	x000AJOO**O+++:    wqz??s   . 
B3A11#BBc                 <   |t          j                    }	 t          | d          5 }|                                }ddd           n# 1 swxY w Y   n9# t          $ r,}|                    | |j        d                    Y d}~dS d}~ww xY wt          || |          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   )r   r   openreadOSErrorr    r   r   )r   r   fcodestrr(   s        r   r   r   6   s     355(D!! 	QffhhG	 	 	 	 	 	 	 	 	 	 	 	 	 	 	     16!9555qqqqq (H---s9   A AA AA AA 
B
!BB
c                 X   |                      d          rdS |                      d          rdS d}	 t          | d          5 }|                    |          }|s	 ddd           dS 	 ddd           n# 1 swxY w Y   n# t          $ r Y dS w xY wt                              |          S )z0Return True if filename points to a Python file.z.pyT~F   r,   N)endswithr-   r.   r/   PYTHON_SHEBANG_REGEXmatch)r   	max_bytesr0   r   s       r   isPythonFiler9   J   s*    t  uI(D!! 	Q66)$$D 	 	 	 	 	 	 	 		 	 	 	 	 	 	 	 	 	 	 	 	 	 	    uu  %%d+++s;   B A5B )B 5A99B <A9=B 
BBc              #     K   | D ]y}t           j                            |          rTt          j        |          D ]>\  }}}|D ]5}t           j                            ||          }t          |          r|V  6?u|V  zdS )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joinr9   )pathsr<   dirpathdirnames	filenamesr   	full_paths          r   r	   r	   `   s         7== 	02 ( (,9 ) ( (H "Wh ? ?I#I.. ('(( JJJJ r   c                 T    d}t          |           D ]}|t          ||          z  }|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   warnings
sourcePaths       r   r   r   s   s;     H$U++ 4 4
Ij(333Or   c                     ddl }	 t          ||           }n# t          $ r Y dS w xY wfd}	 |                     ||           dS # t          $ r Y dS w xY w)zHandles 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.
    r   Nc                 0    t          j                   d S r   )sysexit)sigr0   messages     r   handlerz_exitOnSignal.<locals>.handler   s    r   )signalgetattrAttributeError
ValueError)sigNamerM   rO   	sigNumberrN   s    `   r   _exitOnSignalrU      s     MMMFG,,		    		    i)))))    	s    
&&A 
AAc                  d    t           dt          j                    dt          j                    S )zQ
    Retrieve and format package version along with python version & OS used
    z Python z on )r   platformpython_versionsystem r   r   _get_versionr[      s5    
 [[(13333X_5F5F5FH Ir   c                    ddl }t          dd           t          dd           |                    | d          }|                    d	d
dt	                                 |                    ddd           |                    |          j        }t          j                    }|rt          ||          }n-t          t          j                                        d|          }t          |dk              )z&Entry point for the script "pyflakes".r   NSIGINTz... stoppedSIGPIPEr   z$Check Python source files for errors)progdescriptionz-Vz	--versionversion)actionra   r<   *z7Path(s) of Python file(s) to check. STDIN if not given.)nargshelp)r   z<stdin>)argparserU   ArgumentParseradd_argumentr[   
parse_argsr<   r   r   r   r   rJ   stdinr.   
SystemExit)r_   r   rf   parserr   rF   s         r   r
   r
      s   OOO (M***)Q$$$1W % Y YF
k)\^^TTT
cV  X X X$'',D/11H @!$11))9h??
X\
"
""r   r   )NN)__doc__r   r;   rW   rerJ   pyflakesr   r   r   r   __all__compiler6   r   r   r9   r	   r   rU   r[   r
   rZ   r   r   <module>rr      s    


 				  				 



 ) ) ) ) ) ) ) ) , , , , , ,
L
L
L!rz"IJJ ! ! ! !H. . . .(, , ,,  &     6I I I# # # # # #r   