Qf-dZdZddlZddlZddlZgdZdadadZdZ Gdde Z d Z Gd d Z d Zd ZdZedk(re yy)aThe 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. 6N)checkNannyNagprocess_tokenscd}|D]/}tjj|t|zd}1tjjdtjdy)N  )sysstderrwritestrexit)argssepargs //opt/alt/python312/lib64/python3.12/tabnanny.pyerrprintr sO C s3x(JJTHHQKcZddl} |jtjddd\}}D]"\}}|dk(r t dza|dk(st dza$st dtjdd|D] }t|y#|j$r}t |Yd}~yd}~wwxYw)Nrr qvz-qz-vzUsage:z[-v] file_or_directory ...)getoptr argverrorr filename_onlyverboser)roptsrmsgoars rmainr"(s]]388AB<6 d1 9)A-M 9kG  388A;(DE c  << s&BB* B%%B*c(eZdZdZdZdZdZdZy)rzk Raised by process_tokens() if detecting an ambiguous indent. Captured and handled in check(). c0|||c|_|_|_yN)linenorline)selfr&rr's r__init__zNannyNag.__init__?s+13( TXtyrc|jSr%)r&r(s r get_linenozNannyNag.get_linenoAs {{rc|jSr%)rr+s rget_msgzNannyNag.get_msgCs xxrc|jSr%)r'r+s rget_linezNannyNag.get_lineEs yyrN)__name__ __module__ __qualname____doc__r)r,r.r0rrrr:s=rrctjj|rtjj|strt |dtj |}|D]}tjj||}tjj|rtjj|r&tjj|dddk(st|y tj|}tdkDrt d|z ttj|j  |j%trt |dyy#t$r}t|d|Yd}~yd}~wwxYw#tj"$r*}t|d|Yd}~|j%yd}~wt&$r*}t|d |Yd}~|j%yd}~wt($r*}t|d |Yd}~|j%yd}~wt*$r}|j-}|j/}tr8t d ||fzt d |t |j1n4d |vrd|zdz}t2r t |nt ||t5|Yd}~|j%yd}~wwxYw#|j%wxYw)a~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. z: listing directoryNz.pyz : I/O Error: r zchecking %r ...z: Token Error: z: Indentation Error: z: Syntax Error: z)%r: *** Line %d: trouble in tab city! ***zoffending line: r "z: Clean bill of health.)ospathisdirislinkrprintlistdirjoinnormcasertokenizeopenOSErrorrrgenerate_tokensreadline TokenErrorcloseIndentationError SyntaxErrorrr,r0r.rrepr) filenamesnamefullnamefrnagbadliner's rrrHsB ww}}T277>>$#7  T3 4 4 Dww||D$/H h'GGNN8,  bc+u4h   MM$  { $&'x// ;<8   T34M c23   $450  - c:;(  % 456    .."||~  =wO P $0 1 #++- d{3:#3DeDkgtDz2     syE<-(F"< FFF"K45GK7 K4&H 6K7 K4H<'K7< K4BK/K7/K44K77L c@eZdZd\ZZdZdZdZdZdZ dZ dZ y ) Whitespacez c||_tjtj}}g}dx}x}}|jD]V}||k(r |dz}|dz}||k(r>|dz}|dz}|t |k\r|dg|t |z dzzz}||dz||<d}Vn||_||_t||f|_t |dk|_ y)Nrr ) rawrSSTlennnttuplenorm is_simple) r(wsrVrWcountbrYrZchs rr)zWhitespace.__init__s||Z\\1A((BQwEEqE!VE ?!QC1s5z>A+=$>>E 8a<a%L!O UqrcP|j\}}tt|dz |SNr )r\maxrX)r(r_trailings rlongest_run_of_spacesz Whitespace.longest_run_of_spacess$))x3u:a<**rc|j\}}d}t|t|D]}|||z||zz}||||jzzzS)Nr)r\rangerXrZ)r(tabsizer_reilis r indent_levelzWhitespace.indent_levelsZ))x wE +Aaj58++B,'R$''\222rc4|j|jk(Sr%)r\)r(others requalzWhitespace.equalsyyEJJ&&rc4t|j|jdz}g}td|dzD]X}|j||j|k7s'|j ||j||j|fZ|Srcrdrfrhrlappendr(rnrYr!tss rnot_equal_witnesszWhitespace.not_equal_witness **,++- /12 3 1Q3-B  $(:(:2(>>2,,R0 --b135 rcb|j|jk\ry|jr%|jr|j|jkSt|j |j dz}t d|dzD]'}|j ||j |k\s'yy)NFr T)rYr]rZrdrfrhrl)r(rnrYrts rlesszWhitespace.lesss 66UWW  >>eoo77ehh& & **,++- /12 31Q3-B  $(:(:2(>> rc4t|j|jdz}g}td|dzD]X}|j||j|k\s'|j ||j||j|fZ|Srcrqrss rnot_less_witnesszWhitespace.not_less_witnessrvrN) r1r2r3rVrWr)rfrlroruryr{r5rrrSrSs. DAq*)2+3.' 0 " rrScld|D}d}t|dkDr|dz}|dzdj|zS)Nc38K|]}t|dyw)rN)r).0tups r z#format_witnesses..s 'Qcc#a&kQsz at tab sizer sr z, )rXr?)wfirstsprefixs rformat_witnessesrs= 'Q 'F F 1vz# C<$))F+ ++rc t|y#t$r0}t|j|j|j d}~wwxYwr%)_process_tokensTabErrorrr&rtext)tokenses rrrs:0 0qxx//0s  A+AActj}tj}tj}tjtj f}t dg}d}|D]\}}} } } ||k(rd}||k(red}t |} |dj| s2|dj| } dt| z}t| d|| |j| {||k(rd}|d=|s||vsd}t | } |dj| r|dj| } dt| z}t| d|| y)Nrrr zindent not greater e.g. zindent not equal e.g. )rAINDENTDEDENTNEWLINECOMMENTNLrSryr{rrrrroru)rrrrJUNKindents check_equaltypetokenstartendr'thisguywitnessrs rrrsL __F __FG   X[[ (D"~GK+1'ueS$ 7? K V^K 'G2;##G,!"+66w?03CG3LLuQxd33 NN7 # V^K T-K &G2;$$W-!"+77@.1A'1JJuQxd33Y,2r__main__)r4 __version__r9r rA__all__rrrr" ExceptionrrrSrrrr1r5rrrsv $  1  $ y ?5BDDL,0 44n zFr