
    WOg                         S r SSKrSSKrSSKrSSKrSSKrSSKJrJr  SSKJ	r
  / SQr\R                  " S5      rSS jrSS jrS	 rS
 rS rS rS rSS jrg)z,
API for the command-line I{pyflakes} tool.
    N)checker__version__)reporter)check	checkPathcheckRecursiveiterSourceCodemains#   ^#!.*\bpython(3(\.\d+)?|w)?[dmu]?\sc                    Uc  [         R                  " 5       n [        R                  " XS9n[        R                  " X1S9nUR                  R                  S S9  UR                   H  nUR!                  U5        M     [#        UR                  5      $ ! [         aI  nUR                  XR                  S   UR                  UR                  UR                  5         SnAgSnAf[         a    UR                  US5         gf = f)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                     U R                   $ N)lineno)ms    Q/Users/admin/workspace/ai/Jarvis/env/lib/python3.13/site-packages/pyflakes/api.py<lambda>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35yy7 	0AJJOO*O+::w qzz?  Xvvay!((AHHaffM   +DEs   B 
D?C##DDc                 "   Uc  [         R                  " 5       n [        U S5       nUR                  5       nSSS5        [        WX5      $ ! , (       d  f       N= f! [         a(  nUR                  XR                  S   5         SnAgSnAff = f)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   sy     335(D!QffhG "
 (-- "!   66!95s3   A AA 
AA A 
B&B		Bc                 @   U R                  S5      (       a  gU R                  S5      (       a  gSn [        U S5       nUR                  U5      nU(       d
   SSS5        g SSS5        [        R                  W5      $ ! , (       d  f       N#= f! [         a     gf = f)z0Return True if filename points to a Python file.z.pyT~F   r-   N)endswithr.   r/   r0   PYTHON_SHEBANG_REGEXmatch)r   	max_bytesr1   r   s       r   isPythonFiler:   J   s     I(D!Q66)$D "! "  %%d++ "!  s4   B A?B "B ?
B	B B 
BBc              #   .  #    U  H  n[         R                  R                  U5      (       a`  [         R                  " U5       HD  u  p#nU H8  n[         R                  R	                  X%5      n[        U5      (       d  M4  Uv   M:     MF     M  Uv   M     g7f)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joinr:   )pathsr=   dirpathdirnames	filenamesr   	full_paths          r   r	   r	   `   sn      77==02,9 )H "W ?I#I..' !* 1> J s   A8B>Bc                 J    Sn[        U 5       H  nU[        X15      -  nM     U$ )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   )rA   r   warnings
sourcePaths       r   r   r   s   s,     H$U+
Ij33 ,Or   c                    ^ SSK n [        X 5      nU4S jn UR                  X45        g! [         a     gf = f! [         a     gf = f)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                 2   > [         R                  " T5        g r   )sysexit)sigr1   messages     r   handler_exitOnSignal.<locals>.handler   s    r   )signalgetattrAttributeError
ValueError)sigNamerN   rQ   	sigNumberrO   s    `   r   _exitOnSignalrW      sX     F,	i)   		   	s   + ; 
88
AAc                  p    [         < S[        R                  " 5       < S[        R                  " 5       < 3$ )zI
Retrieve and format package version along with python version & OS used
z Python z on )r   platformpython_versionsystem r   r   _get_versionr]      s'    
 (113X__5FH Ir   c                    SSK n[        SS5        [        SS5        UR                  U SS9nUR                  S	S
S[	        5       S9  UR                  SSSS9  UR                  US9R                  n[        R                  " 5       nU(       a  [        X5      nO)[        [        R                  R                  5       SU5      n[        US:  5      e)z&Entry point for the script "pyflakes".r   NSIGINTz... stoppedSIGPIPEr   z$Check Python source files for errors)progdescriptionz-Vz	--versionversion)actionrc   r=   *z7Path(s) of Python file(s) to check. STDIN if not given.)nargshelp)r   z<stdin>)argparserW   ArgumentParseradd_argumentr]   
parse_argsr=   r   r   r   r   rK   stdinr/   
SystemExit)ra   r   rh   parserr   rG   s         r   r
   r
      s     (M*)Q$$$1W % YF
k)\^T
cV  X$',,D//1H!$1)9h?
X\
""r   r   )NN)__doc__r   r<   rY   rerK   pyflakesr   r   r   r   __all__compiler7   r   r   r:   r	   r   rW   r]   r
   r\   r   r   <module>rt      s`     	  	 
 ) ,
Lzz"IJ !H.(,,& 6I#r   