K idZddlZddlZddlZddlZddlZddlmZmZddlm Z gdZ ejdZ ddZddZd Zd Zd Zd Zd ZddZy)z, API for the command-line I{pyflakes} tool. N)checker __version__)reporter)check checkPathcheckRecursiveiterSourceCodemains#^#!.*\bpython(3(\.\d+)?|w)?[dmu]?\sc|tj} tj||}tj||}|jjd|jD]}|j!|t#|jS#t$rJ}|j ||j d|j|j|jYd}~yd}~wt$r|j|dYywxYw)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 sourcec|jSN)lineno)ms R/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/pyflakes/api.pyzcheck..0s !(()key) modReporter_makeDefaultReporterastparse SyntaxError syntaxErrorargsroffsettext ExceptionunexpectedErrorrCheckermessagessortflakelen) codeStringr rtreeewwarnings rrrs"335yyh7 x0AJJOO*O+:: w qzz? Xqvvay!((AHHaffM   +DEsB D #AC((D D c|tj} t|d5}|j}dddt||S#1swYxYw#t$r)}|j ||j dYd}~yd}~wwxYw)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 rrr6s335 (D ! QffhG  (H --      166!95s- AA A AA BBBc|jdry|jdryd} t|d5}|j|}|s dddy dddtj S#1swYxYw#t$rYywxYw)z0Return True if filename points to a Python file.z.pyT~Fr,N)endswithr-r.r/PYTHON_SHEBANG_REGEXmatch)r max_bytesr0rs r isPythonFiler9JsI (D ! Q66)$D    % %d ++   s. A<A0 A<A<0A95A<< BBc# K|D]{}tjj|rVtj|D]=\}}}|D]2}tjj ||}t |s/|4?x|}yw)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)ospathisdirwalkjoinr9)pathsr<dirpathdirnames filenamesr full_paths rr r `s| 77== 02  (,9 )(H " Wh ?I#I.'( ( Js A1B4BcHd}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@rwarnings sourcePaths rrrss3H$U+4 Ij(334 Orcddl} t||}fd} |j||y#t$rYywxYw#t$rYywxYw)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. rNc0tjyr)sysexit)sigr0messages rhandlerz_exitOnSignal..handlers r)signalgetattrAttributeError ValueError)sigNamerMrO sigNumberrNs ` r _exitOnSignalrUs\ FG,   i)       s ,; 88 AAcftdtjdtjS)zQ Retrieve and format package version along with python version & OS used z Python z on )rplatformpython_versionsystemrr _get_versionr[s' (113X__5F HIrcddl}tddtdd|j|d}|jd d d t |jd dd|j |j }tj}|r t||}n)ttjjd|}t|dkD)z&Entry point for the script "pyflakes".rNSIGINTz ... stoppedSIGPIPEr z$Check Python source files for errors)prog descriptionz-Vz --versionversion)actionrar<*z7Path(s) of Python file(s) to check. STDIN if not given.)nargshelp)rz)argparserUArgumentParser add_argumentr[ parse_argsr<rrrrrJstdinr. SystemExit)r_rrfparserrrFs rr r s(M*)Q  $ $$1W%YF k)\^T cVX   $  ' , ,D//1H !$1)9h? X\ ""rr)NN)__doc__rr;rWrerJpyflakesrrrr__all__compiler6rrr9r rrUr[r rZrrrrsb  ), L!rzz"IJ!H.(,,&   6I#r