bgdZddlZddlZddlZddlZddlZddlmZmZddlm Z gdZ ej dZ ddZddZd Zd Zd Zd Zd ZddZdS)z, API for the command-line I{pyflakes} tool. N)checker __version__)reporter)check checkPathcheckRecursiveiterSourceCodemains#^#!.*\bpython(3(\.\d+)?|w)?[dmu]?\sc*|tj} tj||}nm#t$r>}|||jd|j|j|j Yd}~dSd}~wt$r| |dYdSwxYwtj |}tj|||}|jd|jD]}||t%|jS) 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)filenamerzproblem decoding source) file_tokensr c|jSN)lineno)ms ]/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/pyflakes/api.pyzcheck..1s!()key) modReporter_makeDefaultReporterastparse SyntaxError syntaxErrorargsroffsettext ExceptionunexpectedErrorr make_tokensCheckermessagessortflakelen) codeStringr rtreeerwwarnings rrrs-"355yh777 Xqvay!(AHafMMMqqqqq   +DEEEqq%j11K+IIIAJOO**O+++:  w qz??s. B3A11#BBc<|tj} t|d5}|}dddn #1swxYwYn9#t$r,}|||jdYd}~dSd}~wwxYwt|||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 Nrbr )rropenreadOSErrorr!rr)r rfcodestrr*s rrr7s355 (D ! ! QffhhG                  16!9555qqqqq (H - --s9AA AA  AA A B !BB cX|drdS|drdSd} t|d5}||}|s ddddS dddn #1swxYwYn#t$rYdSwxYwt|S)z0Return True if filename points to a Python file.z.pyT~Fr.N)endswithr/r0r1PYTHON_SHEBANG_REGEXmatch)r max_bytesr2rs r isPythonFiler;Ks*tuI (D ! ! Q66)$$D                          uu % %d + ++s;BA5 B) B5A99B<A9=B BBc#K|D]y}tj|rTtj|D]>\}}}|D]5}tj||}t |r|V6?u|VzdS)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)ospathisdirwalkjoinr;)pathsr>dirpathdirnames filenamesr full_paths rr r as 7==   02  ( (,9 )((H " Wh ? ?I#I..('( ( JJJJrcTd}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)rBrwarnings sourcePaths rrrts;H$U++44 Ij(333 Orcddl} t||}n#t$rYdSwxYwfd} |||dS#t$rYdSwxYw)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. rNc0tjdSr)sysexit)sigr2messages rhandlerz_exitOnSignal..handlers r)signalgetattrAttributeError ValueError)sigNamerOrQ sigNumberrPs ` r _exitOnSignalrWs MMMFG,,      i)))))      s &&A AAcdtdtjdtjS)zQ Retrieve and format package version along with python version & OS used z Python z on )rplatformpython_versionsystemrr _get_versionr]s5 [[(13333X_5F5F5F HIrcddl}tddtdd||d}|d d d t |d dd||j}tj}|rt||}n-ttj d|}t|dk)z&Entry point for the script "pyflakes".rNSIGINTz ... stoppedSIGPIPEr z$Check Python source files for errors)prog descriptionz-Vz --versionversion)actionrcr>*z7Path(s) of Python file(s) to check. STDIN if not given.)nargshelp)rz)argparserWArgumentParser add_argumentr] parse_argsr>rrrrrLstdinr0 SystemExit)rarrhparserrrHs rr r sOOO(M***)Q  $ $$1W%YYF k)\^^TTT cVXXX   $  ' ' ,D/11H @!$11))9h?? X\ " ""rr)NN)__doc__rr=rYrerLpyflakesrrrr__all__compiler8rrr;r rrWr]r r\rrrts  )))))))),,,,,, L L L!rz"IJJ""""J....(,,,,&       6III######r