j]E%h d Z ddlZddlZddlZddlZddlZddlmZmZ ddlm Z
g dZ ej d Z
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 * |t j } t j | | }nm# t $ r>}| ||j d |j |j |j Y d}~dS d}~wt $ r | |d Y dS w xY wt j
| }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 zproblem decoding source)file_tokensr c | j S N)lineno)ms ^/builddir/build/BUILD/cloudlinux-venv-1.0.10/venv/lib/python3.11/site-packages/pyflakes/api.pyzcheck..1 s !( )key)modReporter_makeDefaultReporterastparseSyntaxErrorsyntaxErrorargsr offsettext ExceptionunexpectedErrorr make_tokensCheckermessagessortflakelen)
codeStringr r treeer wwarnings r r r s- " 355yh777 Xqvay!(AHafMMMqqqqq +DEEEqq %j11K+IIIAJOO**O+++: wqz??s .
B3A11#BBc < |t j } t | d 5 }| }ddd n# 1 swxY w Y n9# t $ r,}| | |j d Y d}~dS d}~ww xY wt || | 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
)r r openreadOSErrorr! r r )r r fcodestrr* s r r r 7 s 355
(D
!
! QffhhG 16!9555qqqqq (H---s9 A AA AA AA
B
!BB
c X | d rdS | d rdS d} t | d 5 }| | }|s ddd dS ddd n# 1 swxY w Y n# t $ r Y dS w xY wt | S )z0Return True if filename points to a Python file.z.pyT~F r. N)endswithr/ r0 r1 PYTHON_SHEBANG_REGEXmatch)r max_bytesr2 r s r isPythonFiler; K s* t uI
(D
!
! Q66)$$D
uu %%d+++s; B A5B )B 5A99B <A9=B
BBc # K | D ]y}t j | rTt j | D ]>\ }}}|D ]5}t j || }t | r|V 6?u|V zdS )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 r r r a 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 )rB r warnings
sourcePaths r r r t s; H$U++ 4 4
Ij(333Or c ddl } t || }n# t $ r Y dS w xY wfd} | || dS # t $ r Y dS w xY 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 )sysexit)sigr2 messages r handlerz_exitOnSignal..handler s r )signalgetattrAttributeError
ValueError)sigNamerO rQ sigNumberrP s ` r
_exitOnSignalrW s MMMFG,,
i)))))
s
&&A
AAc d t dt j dt j S )zQ
Retrieve and format package version along with python version & OS used
z Python z on )r platformpython_versionsystem r r _get_versionr] s5
[[(13333X_5F5F5F
H Ir c ddl }t dd t dd | | d }| d d
dt | d
dd | | j }t j }|rt || }n-t t j
d| }t |dk )z&Entry point for the script "pyflakes".r NSIGINTz... stoppedSIGPIPEr
z$Check Python source files for errors)progdescriptionz-Vz --versionversion)actionrc r> *z7Path(s) of Python file(s) to check. STDIN if not given.)nargshelp)r z)argparserW ArgumentParseradd_argumentr]
parse_argsr> r r r r rL stdinr0
SystemExit)ra r rh parserr rH s r r
r
s OOO (M***)Q
$
$$1W % Y YF
k)\^^TTT
cV X X X$'',D/11H @!$11))9h??
X\
"
""r r )NN)__doc__r r= rY rerL pyflakesr r r r __all__compiler8 r r r; r r rW r] r
r\ r r rt s
) ) ) ) ) ) ) ) , , , , , ,
L
L
L!rz"IJJ " " " "J. . . .(, , ,, &
6I I I# # # # # #r