Plan 9 from Bell Labs’s /usr/web/sources/contrib/stallion/root/sys/lib/python2.7/tabnanny.pyo

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


�`^c@s�dZdZddlZddlZddlZddlZeed�sZed��ndddgZd	a	d	a
d
�Zd�Zde
fd��YZd
�Zddd��YZd�Zd�Zedkr��ndS(s�The Tab Nanny despises ambiguous indentation.  She knows no mercy.

tabnanny -- Detection of ambiguous indentation

For the time being this module is intended to be called as a script.
However it is possible to import it into an IDE and use the function
check() described below.

Warning: The API provided by this module is likely to change in future
releases; such changes may not be backward compatible.
t6i�NtNLs4tokenize.NL doesn't exist -- tokenize module too oldtchecktNannyNagtprocess_tokensicGsKd}x.|D]&}tjj|t|��d}q
Wtjjd�dS(Ntt s
(tsyststderrtwritetstr(targstseptarg((s/sys/lib/python2.7/tabnanny.pyterrprint#s


cCs�y#tjtjdd�\}}Wn!tjk
rF}t|�dSXxF|D]>\}}|dkrstdan|dkrNtdaqNqNW|s�tdtjdd�dSx|D]}t|�q�WdS(Nitqvs-qs-vsUsage:is[-v] file_or_directory ...(tgetoptRtargvterrorRt
filename_onlytverboseR(toptsRtmsgtotaR
((s/sys/lib/python2.7/tabnanny.pytmain*s#


cBs2eZdZd�Zd�Zd�Zd�ZRS(sg
    Raised by tokeneater() if detecting an ambiguous indent.
    Captured and handled in check().
    cCs!||||_|_|_dS(N(tlinenoRtline(tselfRRR((s/sys/lib/python2.7/tabnanny.pyt__init__AscCs|jS(N(R(R((s/sys/lib/python2.7/tabnanny.pyt
get_linenoCscCs|jS(N(R(R((s/sys/lib/python2.7/tabnanny.pytget_msgEscCs|jS(N(R(R((s/sys/lib/python2.7/tabnanny.pytget_lineGs(t__name__t
__module__t__doc__RRRR (((s/sys/lib/python2.7/tabnanny.pyR<s
			c	Cs4tjj|�r�tjj|�r�tr:d|fGHntj|�}xq|D]i}tjj||�}tjj|�r�tjj|�s�tjj|d�dkrPt|�qPqPWdSyt	|�}Wn(t
k
r�td||f�dSXtdkrd|GHnytt
j|j��Wn�t
jk
r[}td||f�dStk
r�}td	||f�dStk
r}|j�}|j�}tr�d
||fGHd|fGH|j�GHn>d|kr�|d
}ntr|GHn|G|Gt|�GHdSXtr0d|fGHndS(s~check(file_or_dir)

    If file_or_dir is a directory and not a symbolic link, then recursively
    descend the directory tree named by file_or_dir, checking all .py files
    along the way. If file_or_dir is an ordinary Python source file, it is
    checked for whitespace related problems. The diagnostic messages are
    written to standard output using the print statement.
    s%r: listing directoryi�s.pyNs%r: I/O Error: %sischecking %r ...s%r: Token Error: %ss%r: Indentation Error: %ss)%r: *** Line %d: trouble in tab city! ***soffending line: %rRt"s%r: Clean bill of health.(tostpathtisdirtislinkRtlistdirtjointnormcaseRtopentIOErrorRRttokenizetgenerate_tokenstreadlinet
TokenErrortIndentationErrorRRR RRtrepr(	tfiletnamestnametfullnametfRtnagtbadlineR((s/sys/lib/python2.7/tabnanny.pyRJsR
%
t
WhitespacecBsSeZd\ZZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
RS(s 	c	Cs||_tjtj}}g}d}}}x�|jD]�}||krc|d}|d}q:||kr�|d}|d}|t|�kr�|dg|t|�d}n||d||<d}q:Pq:W||_||_t|�|f|_t|�dk|_	dS(Nii(
trawR;tStTtlentntntttupletnormt	is_simple(	RtwsR=R>tcounttbR@RAtch((s/sys/lib/python2.7/tabnanny.pyR�s(	



"			cCs&|j\}}tt|�d|�S(Ni(RCtmaxR?(RRFttrailing((s/sys/lib/python2.7/tabnanny.pytlongest_run_of_spaces�scCs^|j\}}d}x3t|t|��D]}|||||}q+W||||jS(Ni(RCtrangeR?RA(RttabsizeRFRJtilti((s/sys/lib/python2.7/tabnanny.pytindent_level�s
cCs|j|jkS(N(RC(Rtother((s/sys/lib/python2.7/tabnanny.pytequal�scCs�t|j�|j��d}g}xdtd|d�D]O}|j|�|j|�kr9|j||j|�|j|�f�q9q9W|S(Ni(RIRKRLRPtappend(RRQR@Rtts((s/sys/lib/python2.7/tabnanny.pytnot_equal_witness�s	cCs�|j|jkrtS|jr8|jr8|j|jkSt|j�|j��d}x=td|d�D](}|j|�|j|�krktSqkWtS(Nii(	R@tFalseRDRARIRKRLRPtTrue(RRQR@RT((s/sys/lib/python2.7/tabnanny.pytless�scCs�t|j�|j��d}g}xdtd|d�D]O}|j|�|j|�kr9|j||j|�|j|�f�q9q9W|S(Ni(RIRKRLRPRS(RRQR@RRT((s/sys/lib/python2.7/tabnanny.pytnot_less_witness�s	(R!R"R=R>RRKRPRRRURXRY(((s/sys/lib/python2.7/tabnanny.pyR;�s						cCsLtd�|�}d}t|�dkr7|d}n|ddj|�S(NcSst|d�S(Ni(R
(ttup((s/sys/lib/python2.7/tabnanny.pyt<lambda>ssat tab sizeitsRs, (tmapR?R*(twtfirststprefix((s/sys/lib/python2.7/tabnanny.pytformat_witnesses
s

cCs�tj}tj}tj}tjtjf}td�g}d}xA|D]9\}}}	}
}||krsd}qI||kr�}t|�}|dj|�s�dj|�}
dt	|
�}t
|	d||��n|j|�qI||krd}|d=qI|rI||krId}t|�}|dj|�s�|dj
|�}
dt	|
�}t
|	d||��q�qIqIWdS(NRiii�sindent not greater e.g. sindent not equal e.g. (R.tINDENTtDEDENTtNEWLINEtCOMMENTRR;RXRYRaRRSRRRU(ttokensRbRcRdtJUNKtindentstcheck_equalttypettokentstarttendRtthisguytwitnessR((s/sys/lib/python2.7/tabnanny.pyRs6				

t__main__((R#t__version__R%RRR.thasattrt
ValueErrort__all__RRRRt	ExceptionRRR;RaRR!(((s/sys/lib/python2.7/tabnanny.pyt<module>
s&			:�	7

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].