Ñò
3mÈKc           @   sé   d  Z  d Z d d k Z d d k Z d d k Z d d k Z e e d ƒ p e d ƒ ‚ n d d d g Z d	 a	 d	 a
 d
 „  Z d „  Z d e f d „  ƒ  YZ d „  Z d d d „  ƒ  YZ d „  Z d „  Z e d j o e ƒ  n d S(   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.
t   6iÿÿÿÿNt   NLs4   tokenize.NL doesn't exist -- tokenize module too oldt   checkt   NannyNagt   process_tokensi    c          G   sK   d } x. |  D]& } t  i i | t | ƒ ƒ d } q Wt  i i d ƒ d  S(   Nt    t    s   
(   t   syst   stderrt   writet   str(   t   argst   sept   arg(    (    s   /usr/lib/python2.6/tabnanny.pyt   errprint#   s     
c       
   C   sØ   y# t  i  t i d d ƒ \ }  } Wn# t  i j
 o } t | ƒ d  SXxJ |  D]B \ } } | d j o t d a n | d j o t d a qP qP W| p t d t i d d ƒ d  Sx | D] } t | ƒ qÀ Wd  S(   Ni   t   qvs   -qs   -vs   Usage:i    s   [-v] file_or_directory ...(   t   getoptR   t   argvt   errorR   t   filename_onlyt   verboseR   (   t   optsR   t   msgt   ot   aR   (    (    s   /usr/lib/python2.6/tabnanny.pyt   main*   s"    #
  c           B   s2   e  Z d  Z d „  Z d „  Z d „  Z d „  Z RS(   sg   
    Raised by tokeneater() if detecting an ambiguous indent.
    Captured and handled in check().
    c         C   s!   | | | |  _  |  _ |  _ d  S(   N(   t   linenoR   t   line(   t   selfR   R   R   (    (    s   /usr/lib/python2.6/tabnanny.pyt   __init__A   s    c         C   s   |  i  S(   N(   R   (   R   (    (    s   /usr/lib/python2.6/tabnanny.pyt
   get_linenoC   s    c         C   s   |  i  S(   N(   R   (   R   (    (    s   /usr/lib/python2.6/tabnanny.pyt   get_msgE   s    c         C   s   |  i  S(   N(   R   (   R   (    (    s   /usr/lib/python2.6/tabnanny.pyt   get_lineG   s    (   t   __name__t
   __module__t   __doc__R   R   R   R    (    (    (    s   /usr/lib/python2.6/tabnanny.pyR   <   s
   			c   	      C   sO  t  i i |  ƒ o· t  i i |  ƒ o£ t o d |  f GHn t  i |  ƒ } xu | D]m } t  i i |  | ƒ } t  i i | ƒ o t  i i | ƒ p t  i i | d ƒ d j o t | ƒ qT qT Wd Sy t	 |  ƒ } Wn* t
 j
 o } t d |  | f ƒ d SXt d j o d |  GHn y t t i | i ƒ ƒ Wnö t i j
 o } t d |  | f ƒ d St j
 o } t d	 |  | f ƒ d St j
 o• } | i ƒ  } | i ƒ  } t o* d
 |  | f GHd | f GH| i ƒ  GHnC d |  j o d |  d }  n t o	 |  GHn |  G| Gt | ƒ GHd SXt o d |  f GHn d S(   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: %si   s   checking %r ...s   %r: Token Error: %ss   %r: Indentation Error: %ss)   %r: *** Line %d: trouble in tab city! ***s   offending line: %rR   t   "s   %r: Clean bill of health.(   t   ost   patht   isdirt   islinkR   t   listdirt   joint   normcaseR   t   opent   IOErrorR   R   t   tokenizet   generate_tokenst   readlinet
   TokenErrort   IndentationErrorR   R   R    R   R   t   repr(	   t   filet   namest   namet   fullnamet   fR   t   nagt   badlineR   (    (    s   /usr/lib/python2.6/tabnanny.pyR   J   sT    
'   	t
   Whitespacec           B   sS   e  Z d  \ Z Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 RS(   s    	c   	      C   s  | |  _  t i t i } } g  } d } } } xª |  i  D]Ÿ } | | j o | d } | d } q: | | j of | d } | d } | t | ƒ j o# | d g | t | ƒ d } n | | d | | <d } q: Pq: W| |  _ | |  _ t | ƒ | f |  _ t | ƒ d j |  _	 d  S(   Ni    i   (
   t   rawR;   t   St   Tt   lent   nt   ntt   tuplet   normt	   is_simple(	   R   t   wsR=   R>   t   countt   bR@   RA   t   ch(    (    s   /usr/lib/python2.6/tabnanny.pyR   ›   s*    	
 


#
		c         C   s&   |  i  \ } } t t | ƒ d | ƒ S(   Ni   (   RC   t   maxR?   (   R   RF   t   trailing(    (    s   /usr/lib/python2.6/tabnanny.pyt   longest_run_of_spaces´   s    c         C   s^   |  i  \ } } d } x3 t | t | ƒ ƒ D] } | | | | | } q+ W| | | |  i S(   Ni    (   RC   t   rangeR?   RA   (   R   t   tabsizeRF   RJ   t   ilt   i(    (    s   /usr/lib/python2.6/tabnanny.pyt   indent_level¸   s     c         C   s   |  i  | i  j S(   N(   RC   (   R   t   other(    (    s   /usr/lib/python2.6/tabnanny.pyt   equalÏ   s    c         C   s’   t  |  i ƒ  | i ƒ  ƒ d } g  } xf t d | d ƒ D]Q } |  i | ƒ | i | ƒ j o, | i | |  i | ƒ | i | ƒ f ƒ q9 q9 W| S(   Ni   (   RI   RK   RL   RP   t   append(   R   RQ   R@   R   t   ts(    (    s   /usr/lib/python2.6/tabnanny.pyt   not_equal_witnessÖ   s     	c         C   s¢   |  i  | i  j o t S|  i o | i o |  i | i j St |  i ƒ  | i ƒ  ƒ d } x? t d | d ƒ D]* } |  i | ƒ | i | ƒ j o t Sqp Wt S(   Ni   i   (	   R@   t   FalseRD   RA   RI   RK   RL   RP   t   True(   R   RQ   R@   RT   (    (    s   /usr/lib/python2.6/tabnanny.pyt   lessî   s     	c         C   s’   t  |  i ƒ  | i ƒ  ƒ d } g  } xf t d | d ƒ D]Q } |  i | ƒ | i | ƒ j o, | i | |  i | ƒ | i | ƒ f ƒ q9 q9 W| S(   Ni   (   RI   RK   RL   RP   RS   (   R   RQ   R@   R   RT   (    (    s   /usr/lib/python2.6/tabnanny.pyt   not_less_witnessÿ   s     	(   R!   R"   R=   R>   R   RK   RP   RR   RU   RX   RY   (    (    (    s   /usr/lib/python2.6/tabnanny.pyR;   „   s   						c         C   sN   t  d „  |  ƒ } d } t |  ƒ d j o | d } n | d d i | ƒ S(   Nc         S   s   t  |  d  ƒ S(   i    (   R
   (   t   tup(    (    s   /usr/lib/python2.6/tabnanny.pyt   <lambda>  s    s   at tab sizei   t   sR   s   , (   t   mapR?   R*   (   t   wt   firstst   prefix(    (    s   /usr/lib/python2.6/tabnanny.pyt   format_witnesses
  s
    c         C   s—  t  i } t  i } t  i } t  i t  i f } t d ƒ g } d } xN|  D]F\ } } }	 }
 } | | j o
 d } qI | | j ot d } t | ƒ } | d i | ƒ p= | d i | ƒ } d t	 | ƒ } t
 |	 d | | ƒ ‚ n | i | ƒ qI | | j o d } | d =qI | ot | | j og d } t | ƒ } | d i | ƒ p= | d i | ƒ } d t	 | ƒ } t
 |	 d | | ƒ ‚ qqI qI Wd  S(   NR   i    i   iÿÿÿÿs   indent not greater e.g. s   indent not equal e.g. (   R.   t   INDENTt   DEDENTt   NEWLINEt   COMMENTR   R;   RX   RY   Ra   R   RS   RR   RU   (   t   tokensRb   Rc   Rd   t   JUNKt   indentst   check_equalt   typet   tokent   startt   endR   t   thisguyt   witnessR   (    (    s   /usr/lib/python2.6/tabnanny.pyR     s8    			 

t   __main__(    (   R#   t   __version__R%   R   R   R.   t   hasattrt
   ValueErrort   __all__R   R   R   R   t	   ExceptionR   R   R;   Ra   R   R!   (    (    (    s   /usr/lib/python2.6/tabnanny.pyt   <module>   s&   			:†		7