B >R@sdZddlZddlZddlZeeds.eddddgZdadadd Z d d Z Gd dde Z d dZ GdddZddZddZedkre dS)6NNLz4tokenize.NL doesn't exist -- tokenize module too oldcheckNannyNagprocess_tokenscGs:d}x$|D]}tj|t|d}q WtjddS)N  )sysstderrwritestr)argssepargr+/opt/alt/python37/lib/python3.7/tabnanny.pyerrprint"s  rc Csddl}y|tjddd\}}Wn,|jk rR}z t|dSd}~XYnXx0|D](\}}|dkrrtda|dkrZtdaqZW|stdtjdddSx|D] }t|qWdS)NrZqvz-qz-vzUsage:z[-v] file_or_directory ...)getoptr argverrorr filename_onlyverboser)rZoptsrmsgoarrrrmain)s   rc@s,eZdZddZddZddZddZd S) rcCs||||_|_|_dS)N)linenorline)selfrrrrrr__init__BszNannyNag.__init__cCs|jS)N)r)r rrr get_linenoDszNannyNag.get_linenocCs|jS)N)r)r rrrget_msgFszNannyNag.get_msgcCs|jS)N)r)r rrrget_lineHszNannyNag.get_lineN)__name__ __module__ __qualname__r!r"r#r$rrrrr=sc Cs&tj|rtj|str*td|ft|}xR|D]J}tj||}tj|rdtj|r|tj|dddkr:t |q:WdSyt |}Wn2t k r}zt d||fdSd}~XYnXtdkrtd|zytt |jWnt jk r2}zt d||fdSd}~XYntk rd}zt d||fdSd}~XYntk r}z||}|}trtd ||ftd |ft|n6d |krd |d }trt|nt||t|dSd}~XYnXWd|Xtr"td |fdS)Nz%r: listing directoryz.pyz%r: I/O Error: %srzchecking %r ...z%r: Token Error: %sz%r: Indentation Error: %sz)%r: *** Line %d: trouble in tab city! ***zoffending line: %rr"z%r: Clean bill of health.)ospathisdirislinkrprintlistdirjoinnormcasertokenizeopenOSErrorrrgenerate_tokensreadline TokenErrorIndentationErrorrr"r$r#rreprclose) filenamesnamefullnamefrZnagbadlinerrrrrKsT          c@sLeZdZd\ZZddZddZddZdd Zd d Z d d Z ddZ dS) Whitespacez c Cs||_tjtj}}g}d}}}x~|jD]t}||krJ|d}|d}q,||kr|d}|d}|t|kr|dg|t|d}||d||<d}q,Pq,W||_||_t||f|_t|dk|_ dS)Nrr) rawrASTlennnttuplenorm is_simple) r ZwsrCrDcountbrFrGZchrrrr!s(    zWhitespace.__init__cCs|j\}}tt|d|S)Nr)rImaxrE)r rKtrailingrrrlongest_run_of_spacess z Whitespace.longest_run_of_spacescCsL|j\}}d}x*t|t|D]}|||||}qW||||jS)Nr)rIrangerErG)r tabsizerKrNZilirrr indent_levels  zWhitespace.indent_levelcCs |j|jkS)N)rI)r otherrrrequalszWhitespace.equalcCsft||d}g}xFtd|dD]4}||||kr*||||||fq*W|S)Nr)rMrOrPrSappend)r rTrFrtsrrrnot_equal_witnessszWhitespace.not_equal_witnesscCsr|j|jkrdS|jr(|jr(|j|jkSt||d}x.td|dD]}||||krNdSqNWdS)NFrT)rFrJrGrMrOrPrS)r rTrFrWrrrlesss   zWhitespace.lesscCsft||d}g}xFtd|dD]4}||||kr*||||||fq*W|S)Nr)rMrOrPrSrV)r rTrFrrWrrrnot_less_witnessszWhitespace.not_less_witnessN) r%r&r'rCrDr!rOrSrUrXrZr[rrrrrAsrAcCs8dd|D}d}t|dkr&|d}|dd|S)Ncss|]}t|dVqdS)rN)r ).0tuprrr sz#format_witnesses..z at tab sizersrz, )rEr0)wZfirstsprefixrrrformat_witnessess  rbcCstj}tj}tj}tjtjf}tdg}d}x|D]\}}} } } ||krNd}q2||krd}t|} |d| s|d| } dt | }t | d|| | | q2||krd}|d=q2|r2||kr2d}t| } |d | s2|d | } dt | }t | d|| q2WdS)Nrrrzindent not greater e.g. zindent not equal e.g. )r2INDENTDEDENTNEWLINECOMMENTrrArZr[rbrrVrUrX)tokensrdrerfZJUNKindentsZ check_equaltypetokenstartendrZthisguyZwitnessrrrrrs6       __main__) __version__r*r r2hasattr ValueError__all__rrrr ExceptionrrrArbrr%rrrrs$  =7