U e5d,@sdZddlZddlZddlZeeds.eddddgZdadadd Z d d Z Gd dde Z d dZ GdddZddZddZedkre dS)6NNLz4tokenize.NL doesn't exist -- tokenize module too oldcheckNannyNagprocess_tokenscGs6d}|D]}tj|t|d}qtjddS)N  )sysstderrwritestr)argssepargr /usr/lib64/python3.8/tabnanny.pyerrprint"s rc Csddl}z|tjddd\}}Wn2|jk rX}zt|WYdSd}~XYnX|D](\}}|dkrvtda|dkr^tdaq^|stdtjdddS|D] }t|qdS)NrZqvz-qz-vzUsage:z[-v] file_or_directory ...)getoptr argverrorr filename_onlyverboser)rZoptsrmsgoarrrrmain)s   rc@s,eZdZddZddZddZddZd S) rcCs||||_|_|_dSN)linenorline)selfrrr rrr__init__BszNannyNag.__init__cCs|jSr)rr!rrr get_linenoDszNannyNag.get_linenocCs|jSr)rr#rrrget_msgFszNannyNag.get_msgcCs|jSr)r r#rrrget_lineHszNannyNag.get_lineN)__name__ __module__ __qualname__r"r$r%r&rrrrr=sc CsHtj|rtj|str*td|ft|}|D]J}tj||}tj|rbtj|rztj|dddkr8t |q8dSzt |}Wn8t k r}zt d||fWYdSd}~XYnXtdkrtd|z>ztt |jWn"t jk r@}z t d||fWY WdSd}~XYntk r|}zt d||fWYWdSd}~XYntk r }z|}|}trtd ||ftd |ft|n6d |krd |d }trt|nt||t|WYWdSd}~XYnXW5|XtrDtd |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.)ospathisdirislinkrprintlistdirjoinnormcasertokenizeopenOSErrorrclosergenerate_tokensreadline TokenErrorIndentationErrorrr$r&r%rrepr) filenamesnamefullnamefrZnagbadliner rrrrKsX          c@sLeZdZd\ZZddZddZddZdd Zd d Z d d Z ddZ dS) Whitespacez c Cs||_tjtj}}g}d}}}|jD]v}||krH|d}|d}q*||kr|d}|d}|t|kr|dg|t|d}||d||<d}q*qq*||_||_t||f|_t|dk|_ dS)Nrr) rawrCSTlennnttuplenorm is_simple) r!ZwsrErFcountbrHrIZchrrrr"s(    zWhitespace.__init__cCs|j\}}tt|d|SNr)rKmaxrG)r!rMtrailingrrrlongest_run_of_spacess z Whitespace.longest_run_of_spacescCsH|j\}}d}t|t|D]}|||||}q||||jS)Nr)rKrangerGrI)r!tabsizerMrQZilirrr indent_levels  zWhitespace.indent_levelcCs |j|jkSr)rK)r!otherrrrequalszWhitespace.equalcCsbt||d}g}td|dD]4}||||kr(||||||fq(|SrOrPrRrSrVappendr!rWrHrtsrrrnot_equal_witnessszWhitespace.not_equal_witnesscCsp|j|jkrdS|jr(|jr(|j|jkSt||d}td|dD]}||||krLdSqLdS)NFrT)rHrLrIrPrRrSrV)r!rWrHr\rrrlesss   zWhitespace.lesscCsbt||d}g}td|dD]4}||||kr(||||||fq(|SrOrYr[rrrnot_less_witnessszWhitespace.not_less_witnessN) r'r(r)rErFr"rRrVrXr]r_r`rrrrrCsrCcCs8dd|D}d}t|dkr&|d}|dd|S)Ncss|]}t|dVqdS)rN)r ).0tuprrr sz#format_witnesses..z at tab sizersrz, )rGr2)wZfirstsprefixrrrformat_witnessess  rgcCstj}tj}tj}tjtjf}tdg}d}|D]\}}} } } ||krLd}q0||krd}t|} |d| s|d| } dt | }t | d|| | | q0||krd}|d=q0|r0||kr0d}t| } |d | s0|d | } dt | }t | d|| q0dS)Nrrrzindent not greater e.g. zindent not equal e.g. )r4INDENTDEDENTNEWLINECOMMENTrrCr_r`rgrrZrXr])tokensrirjrkZJUNKindentsZ check_equaltypetokenstartendr ZthisguyZwitnessrrrrrs6       __main__) __version__r,r r4hasattr ValueError__all__rrrr ExceptionrrrCrgrr'rrrrs$  =7