
^Yc           @  s  d  Z  d d l m Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l	 Z	 d d l
 Z
 d d l m Z d d l m Z y$ d d l m Z d d l m Z Wn! e k
 r d d l m Z n Xd Z d	 Z d
 Z yX e j d k re j j d  Z n0 e j j e j d  p>e j j d  d  Z Wn e k
 rae Z n Xd d f Z e j j e j j e   d  Z! d Z" i d d 6d d 6Z# d Z$ e% d d d g  Z& e% e j' d g  e& Z( e% d d d d  d! g  Z) e% d d d" d# d  d! g  Z* e* j+ d$ d% d& d' d d( g  Z, e% d) d* d+ d, d- d. d/ d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 d: d; d< g  Z- e% d=  Z. e% e	 j/ e	 j0 g  Z0 e0 j+ e	 j1 e	 j2 g  Z3 e3 j+ e	 j4 e	 j5 g  Z6 d> d? d@ dA g Z7 e j8 dB  Z9 e j8 dC  Z: e j8 dD  Z; e j8 dE  Z< e j8 dF  Z= e j8 dG  Z> e j8 dH  Z? e j8 dI  Z@ e j8 dJ  ZA e j8 dK  ZB e j8 dL d& j e(   ZC e j8 dM  ZD e j8 dN  ZE e j8 dO  ZF e j8 dP  ZG e j8 dQ  ZH e j8 dR jI d& j dS   dT dU dV dW dX dY dZ d[ d\ d] d^ d_ d` da f D    ZJ e j8 db  ZK e	 jL dc g jM  jN e  dd dc k ZO de   ZP df   ZQ dg   ZR dh   ZS di   ZT dj   ZU dk   ZV dl   ZW dm   ZX dn   ZY do   ZZ dp   Z[ dq   Z\ dr   Z] ds   Z^ dt   Z_ du   Z` dv   Za dw   Zb dx   Zc dy   Zd dz   Ze d{   Zf d|   Zg d}   Zh d~   Zi d   Zj d   Zk d   Zl d   Zm d   Zn d   Zo e jp d f k  rd   Zq e j8 d  jr Zs e jt ju Zv n d   Zq ew js Zs d   Zv e j8 d e jx  jy Zz d   Z{ d   Z| e d d  Z} e j~ d  Z e d  Z d   Z d   Z eO rge d  Z n  i i  d 6i  d 6i  d 6Z d   Z e d  Z d   Z e   d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e d  Z d   Z e e e e d  Z d d  Z d   Z e d k re   n  d S(   s  
Check Python source code formatting, according to PEP 8.

For usage and a list of options, try this:
$ python pycodestyle.py -h

This program and its regression test suite live here:
https://github.com/pycqa/pycodestyle

Groups of errors and warnings:
E errors
W warnings
100 indentation
200 whitespace
300 blank lines
400 imports
500 line length
600 deprecation
700 statements
900 syntax error
i(   t   with_statementN(   t   fnmatch(   t   OptionParser(   t   RawConfigParser(   t   TextIOWrappers   2.3.1s'   .svn,CVS,.bzr,.hg,.git,__pycache__,.toxs!   E121,E123,E126,E226,E24,E704,W503t   win32s   ~\.pycodestylet   XDG_CONFIG_HOMEs	   ~/.configt   pycodestyles	   setup.cfgs   tox.init	   testsuiteiO   s+   %(path)s:%(row)d:%(col)d: %(code)s %(text)st   defaults%   %(path)s:%(row)d: [%(code)s] %(text)st   pylinti   t   Falset   Nonet   Truet   prints   >>s   **t   *t   +t   -t   /s   //t   ^t   &t   |s   <<t   %s   **=s   *=s   /=s   //=s   +=s   -=s   !=s   <>t   <t   >s   %=s   ^=s   &=s   |=s   ==s   <=s   >=s   <<=s   >>=t   =s    	t   directoriest   filess   logical liness   physical liness   ([ \t]*)s   raise\s+\w+\s*,s   raise\s+\w+\s*,.*,\s*\w+\s*$s   \b[A-Z]\d{3}\bs	   u?r?["\']s   [[({] | []}),;:]s   [,;:]\s*(?:  |\t)s?   (\bNone|\bFalse|\bTrue)?\s*([=!]=)\s*(?(1)|(None|False|True))\bs!   \b(not)\s+[^][)(}{ ]+\s+(in|is)\ssE   (?:[=!]=|is(?:\s+not)?)\s*type(?:s.\w+Type|\s*\(\s*([^)]*[^ )])\s*\))s   (\s*)\b(?:%s)\b(\s*)s'   (?:[^,\s])(\s*)(?:[-+*/|!<=>%&^]+)(\s*)s
   \blambda\bs*   ^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@.*$s   ^(async\s+def|def)s#   ^(async\s+def\s+|def\s+|class\s+|@)s	   ^\s*({0})c         c  s!   |  ] } | j  d  d  Vq d S(   t    s   \s+N(   t   replace(   t   .0t   s(    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pys	   <genexpr>   s    t   defs	   async deft   fors	   async fort   ift   elift   elset   tryt   exceptt   finallyt   withs
   async witht   classt   whiles   ^__([^\s]+)__ = s   #
i   c         C  sO   t  j |   j d  } x0 t |  D]" \ } } | | k r% | d f Sq% Wd S(   sI  Never mix tabs and spaces.

    The most popular way of indenting Python is with spaces only.  The
    second-most popular way is with tabs only.  Code indented with a mixture
    of tabs and spaces should be converted to using spaces exclusively.  When
    invoking the Python command line interpreter with the -t option, it issues
    warnings about code that illegally mixes tabs and spaces.  When using -tt
    these warnings become errors.  These options are highly recommended!

    Okay: if a == 0:\n        a = 1\n        b = 1
    E101: if a == 0:\n        a = 1\n\tb = 1
    i   s/   E101 indentation contains mixed spaces and tabsN(   t   INDENT_REGEXt   matcht   groupt	   enumerate(   t   physical_linet   indent_chart   indentt   offsett   char(    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   tabs_or_spaces   s    c         C  s;   t  j |   j d  } d | k r7 | j d  d f Sd S(   s   For new projects, spaces-only are strongly recommended over tabs.

    Okay: if True:\n    return
    W191: if True:\n\treturn
    i   s   	s   W191 indentation contains tabsN(   R+   R,   R-   t   index(   R/   R1   (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   tabs_obsolete   s    c         C  si   |  j  d  }  |  j  d  }  |  j  d  }  |  j  d  } |  | k re | r^ t |  d f Sd	 Sn  d S(
   s  Trailing whitespace is superfluous.

    The warning returned varies on whether the line itself is blank, for easier
    filtering for those who want to indent their blank lines.

    Okay: spam(1)\n#
    W291: spam(1) \n#
    W293: class Foo(object):\n    \n    bang = 12
    s   
s   s   s    	s   W291 trailing whitespacei    s#   W293 blank line contains whitespaceN(   i    s#   W293 blank line contains whitespace(   t   rstript   len(   R/   t   stripped(    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   trailing_whitespace   s    
c         C  sE   | | k rA |  j    } | s" d S| |  k rA t |   d f Sn  d S(   s   Trailing blank lines are superfluous.

    Okay: spam(1)
    W391: spam(1)\n

    However the last line should end with a new line (warning W292).
    i    s   W391 blank line at end of files   W292 no newline at end of fileN(   i    s   W391 blank line at end of file(   R7   R8   (   R/   t   linest   line_numbert   total_linest   stripped_last_line(    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   trailing_blank_lines   s    c         C  s   |  j    } t |  } | | k r | r | j   } t |  d k rO | sq t |  d k r | d d k r t |  t | d  | d k  r d St | d  r y t | j d	   } Wq t k
 r q Xn  | | k r | d
 | | f f Sn  d S(   s  Limit all lines to a maximum of 79 characters.

    There are still many devices around that are limited to 80 character
    lines; plus, limiting windows to 80 characters makes it possible to have
    several windows side-by-side.  The default wrapping on such devices looks
    ugly.  Therefore, please limit all lines to a maximum of 79 characters.
    For flowing long blocks of text (docstrings or comments), limiting the
    length to 72 characters is recommended.

    Reports error E501.
    i   i   i    t   #ii   Nt   decodes   utf-8s'   E501 line too long (%d > %d characters)(   R7   R8   t   splitt   hasattrRA   t   UnicodeError(   R/   t   max_line_lengtht	   multilinet   noqat   linet   lengtht   chunks(    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   maximum_line_length   s     "$c	         c  s  | d k  r | r d S| j  d  r7 | rd Vqn`| d k sU | rg | d k rg d d | f Vn0t j |   r]| r<| p | | k  p t j |  sZ| }	 t }
 xw | | d d d  D]^ } | j   r t |  |	 k  r t |  }	 | j   j  d	  }
 |
 s|	 d k rPqq q W|
 r1d Vq9d VqZq| d k rd d | f Vqn: |  r| r| d k r| j  d  rd d | f Vn  d S(   sC  Separate top-level function and class definitions with two blank lines.

    Method definitions inside a class are separated by a single blank line.

    Extra blank lines may be used (sparingly) to separate groups of related
    functions.  Blank lines may be omitted between a bunch of related
    one-liners (e.g. a set of dummy implementations).

    Use blank lines in functions, sparingly, to indicate logical sections.

    Okay: def a():\n    pass\n\n\ndef b():\n    pass
    Okay: def a():\n    pass\n\n\nasync def b():\n    pass
    Okay: def a():\n    pass\n\n\n# Foo\n# Bar\n\ndef b():\n    pass
    Okay: default = 1\nfoo = 1
    Okay: classify = 1\nfoo = 1

    E301: class Foo:\n    b = 0\n    def bar():\n        pass
    E302: def a():\n    pass\n\ndef b(n):\n    pass
    E302: def a():\n    pass\n\nasync def b(n):\n    pass
    E303: def a():\n    pass\n\n\n\ndef b(n):\n    pass
    E303: def a():\n\n\n\n    pass
    E304: @decorator\n\ndef a():\n    pass
    E305: def a():\n    pass\na()
    E306: def a():\n    def b():\n        pass\n    def c():\n        pass
    i   Nt   @i    s/   E304 blank lines found after function decoratori   s   E303 too many blank lines (%d)is   def s>   E306 expected 1 blank line before a nested definition, found 0s#   E301 expected 1 blank line, found 0s%   E302 expected 2 blank lines, found %ds   class sH   E305 expected 2 blank lines after class or function definition, found %d(   i    s/   E304 blank lines found after function decorator(   i    s>   E306 expected 1 blank line before a nested definition, found 0(   i    s#   E301 expected 1 blank line, found 0(   s   def s   class (   t
   startswitht   STARTSWITH_TOP_LEVEL_REGEXR,   t   DOCSTRING_REGEXR   t   stript   expand_indentt   lstrip(   t   logical_linet   blank_linest   indent_levelR<   t   blank_beforet   previous_logicalt    previous_unindented_logical_linet   previous_indent_levelR;   t   ancestor_levelt   nestedRH   (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyRT      s8    c         c  s   |  } x t  j |  D] } | j   } | j   } | j   } | | d k rf | d d | f Vq | | d d k r | d k r d n d } | d | | f f Vq q Wd	 S(
   sH  Avoid extraneous whitespace.

    Avoid extraneous whitespace in these situations:
    - Immediately inside parentheses, brackets or braces.
    - Immediately before a comma, semicolon, or colon.

    Okay: spam(ham[1], {eggs: 2})
    E201: spam( ham[1], {eggs: 2})
    E201: spam(ham[ 1], {eggs: 2})
    E201: spam(ham[1], { eggs: 2})
    E202: spam(ham[1], {eggs: 2} )
    E202: spam(ham[1 ], {eggs: 2})
    E202: spam(ham[1], {eggs: 2 })

    E203: if x == 4: print x, y; x, y = y , x
    E203: if x == 4: print x, y ; x, y = y, x
    E203: if x == 4 : print x, y; x, y = y, x
    R   i   s   E201 whitespace after '%s't   ,s   }])t   E202t   E203s   %s whitespace before '%s'N(   t   EXTRANEOUS_WHITESPACE_REGEXt   finditerR-   RP   t   start(   RS   RH   R,   t   textR3   t   foundt   code(    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   extraneous_whitespace<  s    c         c  s   x t  j |   D] } | j   \ } } d | k rK | j d  d f Vn) t |  d k rt | j d  d f Vn  d | k r | j d  d f Vq t |  d k r | j d  d f Vq q Wd S(	   s   Avoid extraneous whitespace around keywords.

    Okay: True and False
    E271: True and  False
    E272: True  and False
    E273: True and\tFalse
    E274: True\tand False
    s   	i   s   E274 tab before keywords#   E272 multiple spaces before keywordi   s   E273 tab after keywords"   E271 multiple spaces after keywordN(   t   KEYWORD_REGEXR`   t   groupsRa   R8   (   RS   R,   t   beforet   after(    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   whitespace_around_keywords\  s    	c         c  s_   |  } d } | j  d  r[ | j |  } d | k  r[ | t |  d } | d f Vq[ n  d S(   s   Multiple imports in form from x import (a, b, c) should have space
    between import statement and parenthesised name list.

    Okay: from foo import (bar, baz)
    E275: from foo import(bar, baz)
    E275: from importable.module import(bar, baz)
    s    import(s   from ii   s%   E275 missing whitespace after keywordN(   RM   t   findR8   (   RS   RH   t	   indicatorRc   t   pos(    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt'   missing_whitespace_after_import_keywords  s    c         c  s   |  } x t  t |  d  D] } | | } | d k r | | d t k r | |  } | d k r | j d  | j d  k r | j d  | j d  k  r q n  | d k r | | d d k r q n  | d	 | f Vq q Wd
 S(   s   Each comma, semicolon or colon should be followed by whitespace.

    Okay: [a, b]
    Okay: (3,)
    Okay: a[1:4]
    Okay: a[:4]
    Okay: a[1:]
    Okay: a[1:4:2]
    E231: ['a','b']
    E231: foo(bar,baz)
    E231: [{'a':'b'}]
    i   s   ,;:t   :t   [t   ]t   {R\   t   )s"   E231 missing whitespace after '%s'N(   t   rangeR8   t
   WHITESPACEt   countt   rfind(   RS   RH   R5   R3   Rh   (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   missing_whitespace  s    
 
* c         c  s   |  r d n d } |  r d n d } | d rJ d | d | d f f Vn  | j  d  } | r | | k r d | d	 | d
 f f Vn/ | r | | k r d | d | d f f Vn  d S(   s  Use 4 spaces per indentation level.

    For really old code that you don't want to mess up, you can continue to
    use 8-space tabs.

    Okay: a = 1
    Okay: if a == 0:\n    a = 1
    E111:   a = 1
    E114:   # a = 1

    Okay: for item in items:\n    pass
    E112: for item in items:\npass
    E115: for item in items:\n# Hi\n    pass

    Okay: a = 1\nb = 2
    E113: a = 1\n    b = 2
    E116: a = 1\n    # b = 2
    i    i   s   E11%d %ss   E11%d %s (comment)i   i   s%   indentation is not a multiple of fourRo   i   s   expected an indented blocks   unexpected indentationN(   t   endswith(   RS   RW   R0   RU   RY   t   ct   tmplt   indent_expect(    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   indentation  s    
c   '      c  sE  | d d d } d | d d d | } | s> | d k rB d S|  j  d  }	 d }
 } | d k rm d) n d* } d g | } d g | } d g g } d g } i  } | d d } d } t } | d g } | d
 k r d | d d j   GHn  x| D]\ } } } } } |
 | d | k  } | rO| d | }
 | oI| t k } n  | r| } | d
 k ryd | j   GHn  t |  | | |
 <| t j k o| d k } x@ t | |  D]. } | |
 | | } | | k } | rPqqW| | r| | | k } n  | o+| d k o+| j	 | d  } | rc| | rc| d | | k r| d f Vqq| r| r| r| d f Vqq| | r| d | | k  r| t
 k	 r| d f Vqq| s|	 r| |
 d	 k r| r| r| d f Vn  | | | <q| t
 k r#| d | | <q| | t f k r8q| d k rMd+ }  nR | | r`d, }  n? | rz| | rzd- }  n% | | | <| d k rd. }  n d/ }  | d |  f Vn  | |
 r| t j t j f k r| | r| d | | <t
 | | d <| d k rd | | d f GHqn | t j t j f k sC| d0 k rTt | | d <nj | r|
 r| r| d" k rt
 | | d d <n4 | d k r| | d j   r| | j |
  n  | t j k r| d# k rl| d 7} | j d  | j d  t |  | k r| j g   n  | | j |
  | |
 c d 7<| d k rod$ | | d | | f GHqon| d% k ro| d k ro| j   p| d }! | j   x1 t |  D]# }" | |" |! k rd | |" <qqWx* t |  D] }# |# |! k r| |# =qqW| | d 3| d 8} | r1t
 | | | <n  x; t |
 d d  D]$ }$ | |$ rD| |$ c d 8<PqDqDWn  t |  | d k st  | d | k r| | | d <qn  | d | d k } | r | |
 | | d | <q q W|	 rAt |  | d k rA| d | d d f }% | r)d& }& n d' }& |% d( |& f Vn  d S(1   s2  Continuation lines indentation.

    Continuation lines should align wrapped elements either vertically
    using Python's implicit line joining inside parentheses, brackets
    and braces, or using a hanging indent.

    When using a hanging indent these considerations should be applied:
    - there should be no arguments on the first line, and
    - further indentation should be used to clearly distinguish itself as a
      continuation line.

    Okay: a = (\n)
    E123: a = (\n    )

    Okay: a = (\n    42)
    E121: a = (\n   42)
    E122: a = (\n42)
    E123: a = (\n    42\n    )
    E124: a = (24,\n     42\n)
    E125: if (\n    b):\n    pass
    E126: a = (\n        42)
    E127: a = (24,\n      42)
    E128: a = (24,\n    42)
    E129: if (a or\n    b):\n    pass
    E131: a = (\n    42\n 24)
    i    i   i   iNRo   s   	i   i   i   s   >>> s   ... s   ]})s6   E124 closing bracket does not match visual indentations+   E133 closing bracket is missing indentations7   E128 continuation line under-indented for visual indentsI   E123 closing bracket does not match indentation of opening bracket's linet   E122s    missing indentation or outdentedt   E127s   over-indented for visual indentt   E131s   unaligned for hanging indentt   E126s    over-indented for hanging indentt   E121s!   under-indented for hanging indents   %s continuation line %ss   bracket depth %s indent to %st   ut   urt   bt   brR"   s   ([{s.   bracket depth %s seen, col %s, visual min = %ss   )]}s   E129 visually indented lines   E125 continuation lines(   %s with same indent as next logical line(   i   (   i   i   (   R~   s    missing indentation or outdented(   R   s   over-indented for visual indent(   R   s   unaligned for hanging indent(   R   s    over-indented for hanging indent(   R   s!   under-indented for hanging indent(   R   s   urR   s   br(   Ry   R   R   R7   t   NEWLINERQ   t   tokenizet   OPt   reversedt   getR   t   strt   NLt   COMMENTt   STRINGt   isspacet   appendR8   t   popRt   t   listt   AssertionError('   RS   t   tokensRU   t   hang_closingR0   RG   t   verboset	   first_rowt   nrowst   indent_nextt   rowt   deptht   valid_hangst   parenst
   rel_indentt	   open_rowst   hangst   indent_chancest   last_indentt   visual_indentt   last_token_multilineR1   t
   token_typeRb   Ra   t   endRH   t   newlinet   close_brackett   open_rowt   hangt   hanging_indentt   errort   prev_indentt   dt   indt   idxRm   Rd   (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   continued_indentation  s    
	
	
		
	
! 



	c         c  s   | d \ } } } } } x t  d t |   D] } | | \ } } }	 }
 } | t j k r | d k r |	 | k r | t j k s | d k r | d k  s | | d d d k r t j |  r | d | f Vn  | } | } |
 } q/ Wd S(	   s  Avoid extraneous whitespace.

    Avoid extraneous whitespace in the following situations:
    - before the open parenthesis that starts the argument list of a
      function call.
    - before the open parenthesis that starts an indexing or slicing.

    Okay: spam(1)
    E211: spam (1)

    Okay: dict['key'] = list[index]
    E211: dict ['key'] = list[index]
    E211: dict['key'] = list [index]
    i    i   s   ([s   }])i   R)   s   E211 whitespace before '%s'N(   Rt   R8   R   R   t   NAMEt   keywordt	   iskeyword(   RS   R   t	   prev_typet	   prev_textt   __t   prev_endR5   R   Rb   Ra   R   (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   whitespace_before_parameters  s    $c         c  s   x t  j |   D] } | j   \ } } d | k rK | j d  d f Vn) t |  d k rt | j d  d f Vn  d | k r | j d  d f Vq t |  d k r | j d  d f Vq q Wd S(	   s   Avoid extraneous whitespace around an operator.

    Okay: a = 12 + 3
    E221: a = 4  + 5
    E222: a = 4 +  5
    E223: a = 4\t+ 5
    E224: a = 4 +\t5
    s   	i   s   E223 tab before operators$   E221 multiple spaces before operatori   s   E224 tab after operators#   E222 multiple spaces after operatorN(   t   OPERATOR_REGEXR`   Rg   Ra   R8   (   RS   R,   Rh   Ri   (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   whitespace_around_operator  s    	c         c  sr  d } t  } t j } d } } xL| D]D\ } } }	 }
 } | t k rM q& n  | d k rf | d 7} n | d k r | d 8} n  | ru|	 | k r | t k	 r | d r | d d f Vn  t  } qX| d k r | d k r qX| t k s | d r| d f Vnj | d
 k rld \ } } | d k r5d \ } } n | t k rPd \ } } n  | d d | | f f Vn  t  } n | t j k rX| d k	 rX| d k r| rni | t k rt } nT | t k r| t j k r| d k n	 | t	 k rd } qn | t
 k rd } n  | d k r/| |	 | k f } qX| rX|	 | k rX| d f Vt  } qXn  | } | } |
 } q& Wd S(   sA  Surround operators with a single space on either side.

    - Always surround these binary operators with a single space on
      either side: assignment (=), augmented assignment (+=, -= etc.),
      comparisons (==, <, >, !=, <=, >=, in, not in, is, is not),
      Booleans (and, or, not).

    - If operators with different priorities are used, consider adding
      whitespace around the operators with the lowest priorities.

    Okay: i = i + 1
    Okay: submitted += 1
    Okay: x = x * 2 - 1
    Okay: hypot2 = x * x + y * y
    Okay: c = (a + b) * (a - b)
    Okay: foo(bar, key='word', *args, **kwargs)
    Okay: alpha[:-i]

    E225: i=i+1
    E225: submitted +=1
    E225: x = x /2 - 1
    E225: z = x **y
    E226: c = (a+b) * (a-b)
    E226: hypot2 = x*x + y*y
    E227: c = a|b
    E228: msg = fmt%(errno, errmsg)
    i    t   (t   lambdai   Rs   s'   E225 missing whitespace around operatorR   R   R   s   **t   E226t
   arithmeticR   t   E228t   modulot   E227s   bitwise or shifts(   %s missing whitespace around %s operatorR   s   }])N(   R   s   lambda(   R   R   (   R   R   (   R   R   (   R   s   bitwise or shift(   R   R   R   R   t   SKIP_COMMENTSR   t   ARITHMETIC_OPt   WS_NEEDED_OPERATORSt   UNARY_OPERATORSt   KEYWORDSt   WS_OPTIONAL_OPERATORS(   RS   R   R   t
   need_spaceR   R   R   R   Rb   Ra   R   RH   Rd   t   optype(    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt"   missing_whitespace_around_operator  sb    	
	
			c         c  s{   |  } xn t  j |  D]] } | j   d } d | j   k rZ | d | j   d f Vq | d | j   d f Vq Wd S(   s   Avoid extraneous whitespace after a comma or a colon.

    Note: these checks are disabled by default

    Okay: a = (1, 2)
    E241: a = (1,  2)
    E242: a = (1,\t2)
    i   s   	s   E242 tab after '%s'i    s   E241 multiple spaces after '%s'N(   t   WHITESPACE_AFTER_COMMA_REGEXR`   Ra   R-   (   RS   RH   t   mRc   (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   whitespace_around_comma  s    	c         c  sx  d } t  } d	 } t  } t t j |    } d } x>| D]6\ } }	 }
 } } | t j k rd q: n  | r t  } |
 | k r | | f Vq n  | t j k rj|	 d k r | d 7} n |	 d k r | d 8} n | r |	 d k r | d k r t } nc | r|	 d k r| d k rt  } n< | rX|	 d k rX| rXt } |
 | k rX| | f VqXn  | sjt  } qjn  | } q: Wd	 S(
   s  Don't use spaces around the '=' sign in function arguments.

    Don't use spaces around the '=' sign when used to indicate a
    keyword argument or a default parameter value.

    Okay: def complex(real, imag=0.0):
    Okay: return magic(r=real, i=imag)
    Okay: boolean(a == b)
    Okay: boolean(a != b)
    Okay: boolean(a <= b)
    Okay: boolean(a >= b)
    Okay: def foo(arg: int = 42):
    Okay: async def foo(arg: int = 42):

    E251: def complex(real, imag = 0.0):
    E251: return magic(r = real, i = imag)
    i    s8   E251 unexpected spaces around keyword / parameter equalss   ([i   s   )]Ro   R\   R   N(	   R   R   t   boolt   STARTSWITH_DEF_REGEXR,   R   R   R   R   (   RS   R   R   t   no_spaceR   t   annotated_func_argt   in_deft   messageR   Rb   Ra   R   RH   (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt(   whitespace_around_named_parameter_equals)  s:    		c         c  sh  d } x[| D]S\ } } } } } | t  j k rH| | d  j   } | r | d | d k r | d | d d k  r | d f Vq n  | j d  \ }	 }
 } |	 d k o |	 j d  d  p d } | r | s | d  t k rE| d f VqEq`| r`| d	 k s| d d k r`| d k r.| d
 f VqE| rE| d f VqEq`q | t  j k r | } q q Wd S(   s{  Separate inline comments by at least two spaces.

    An inline comment is a comment on the same line as a statement.  Inline
    comments should be separated by at least two spaces from the statement.
    They should start with a # and a single space.

    Each line of a block comment starts with a # and a single space
    (unless it is indented text inside the comment).

    Okay: x = x + 1  # Increment x
    Okay: x = x + 1    # Increment x
    Okay: # Block comment
    E261: x = x + 1 # Increment x
    E262: x = x + 1  #Increment x
    E262: x = x + 1  #  Increment x
    E265: #Block comment
    E266: ### Block comment
    i    i   i   s.   E261 at least two spaces before inline commentR   s   #:R@   s*   E262 inline comment should start with '# 't   !s)   E265 block comment should start with '# 's+   E266 too many leading '#' for block commentN(   i    i    (   R   R   RP   t	   partitionRR   Ru   R   (   RS   R   R   R   Rb   Ra   R   RH   t   inline_commentt   symbolt   spt   commentt
   bad_prefix(    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   whitespace_before_comment[  s(    ,%"c         c  sU   |  } | j  d  rQ | j d  } d | k  rQ d | |  k rQ | d f VqQ n  d S(   s   Place imports on separate lines.

    Okay: import os\nimport sys
    E401: import sys, os

    Okay: from subprocess import Popen, PIPE
    Okay: from myclas import MyClass
    Okay: from foo.bar.yourclass import YourClass
    Okay: import myclass
    Okay: import foo.bar.yourclass
    s   import R\   it   ;s!   E401 multiple imports on one lineN(   RM   Rk   (   RS   RH   Rc   (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   imports_on_separate_lines  s
    c         #  s   d   } d } | r d S|  s# d S| r- d S|      j  d  sQ   j  d  rn | j d	 t  r d Vq nx t j t    r d St   f d   | D  r d S|    r | j d t  r t | d	 <q t | d <n
 t | d	 <d S(   s  Place imports at the top of the file.

    Always put imports at the top of the file, just after any module comments
    and docstrings, and before module globals and constants.

    Okay: import os
    Okay: # this is a comment\nimport os
    Okay: '''this is a module docstring'''\nimport os
    Okay: r'''this is a module docstring'''\nimport os
    Okay:
    try:\n\timport x\nexcept ImportError:\n\tpass\nelse:\n\tpass\nimport y
    Okay:
    try:\n\timport x\nexcept ImportError:\n\tpass\nfinally:\n\tpass\nimport y
    E402: a=1\nimport os
    E402: 'One string'\n"Two string"\nimport os
    E402: a=1\nfrom sys import x

    Okay: if x:\n    import os
    c         S  sd   |  d d k r |  d }  n  |  r@ |  d d k r@ |  d }  n  |  oc |  d d k pc |  d d k S(   Ni    t   uUbBi   t   rRt   "t   '(    (   RH   (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   is_string_literal  s
    R%   R&   R$   R'   Ns   import s   from t   seen_non_importsi    s+   E402 module level import not at top of filec         3  s   |  ] }   j  |  Vq d  S(   N(   RM   (   R   t   kw(   RH   (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pys	   <genexpr>  s    t   seen_docstring(   s   trys   excepts   elses   finally(   i    s+   E402 module level import not at top of file(   RM   R   R   t   reR,   t   DUNDER_REGEXt   anyR   (   RS   RU   t   checker_stateRG   R   t   allowed_try_keywords(    (   RH   s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   module_imports_on_top_of_file  s*    	c         c  s  |  } t  |  d } | j d  } d } t d   d D  } x&d | k  o[ | k  n rit | | | !|  | d | d k rJ| d	 | d
 k rJ| d | d k rJt j | d |  } | r| | j    j   } | d d k rt | d  j	    rd Vn  Pn  t
 j |  r*d VqJt j |  rJ| d f VqJn  | } | j d | d  } qD W| j d  } xK d | k  r| | k  r| d f Vn | d f V| j d | d  } q|Wd S(   s  Compound statements (on the same line) are generally discouraged.

    While sometimes it's okay to put an if/for/while with a small body
    on the same line, never do this for multi-clause statements.
    Also avoid folding such long lines!

    Always use a def statement instead of an assignment statement that
    binds a lambda expression directly to a name.

    Okay: if foo == 'blah':\n    do_blah_thing()
    Okay: do_one()
    Okay: do_two()
    Okay: do_three()

    E701: if foo == 'blah': do_blah_thing()
    E701: for x in lst: total += x
    E701: while t < 10: t = delay()
    E701: if foo == 'blah': do_blah_thing()
    E701: else: do_non_blah_thing()
    E701: try: something()
    E701: finally: cleanup()
    E701: if foo == 'blah': one(); two(); three()
    E702: do_one(); do_two(); do_three()
    E703: do_four();  # useless semicolon
    E704: def f(x): return 2*x
    E731: f = lambda x: 2*x
    i   Ro   i    c         s  s   |  ] } | d  f Vq d S(   i    N(    (   R   R3   (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pys	   <genexpr>  s    s   {}[]()iRr   t   }Rp   Rq   R   Rs   R   s1   E731 do not assign a lambda expression, use a defs*   E704 multiple statements on one line (def)s,   E701 multiple statements on one line (colon)R   s0   E702 multiple statements on one line (semicolon)s$   E703 statement ends with a semicolonN(   i    s1   E731 do not assign a lambda expression, use a def(   i    s*   E704 multiple statements on one line (def)(   R8   Rk   t   dictt   update_countst   LAMBDA_REGEXt   searchRa   R7   t   isidentifierRP   R   R,   t!   STARTSWITH_INDENT_STATEMENT_REGEX(   RS   RH   t	   last_charRc   t
   prev_foundt   countst	   lambda_kwRh   (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   compound_statements  s8    &c         c  s;  d } } } t  } d	 } x| D]\ } } }	 }
 } | t j k rN t } n  |	 d | k r | r | r | r | d f Vn  |
 d | k r | j d  j d  r |
 d t | j   d  d f } n d	 } |
 d } } n
 |	 d } | t j	 k r! | d k r| d 7} q3| d k r3| d 8} q3q! q! Wd	 S(
   s?  Avoid explicit line join between brackets.

    The preferred way of wrapping long lines is by using Python's implied line
    continuation inside parentheses, brackets and braces.  Long lines can be
    broken over multiple lines by wrapping expressions in parentheses.  These
    should be used in preference to using a backslash for line continuation.

    E502: aaa = [123, \\n       123]
    E502: aaa = ("bbb " \\n       "ccc")

    Okay: aaa = [123,\n       123]
    Okay: aaa = ("bbb "\n       "ccc")
    Okay: aaa = "bbb " \\n    "ccc"
    Okay: aaa = 123  # \\
    i    s0   E502 the backslash is redundant between bracketss   
s   \ii   s   ([{s   )]}N(
   R   R   R   R   R   R7   Ry   R8   t
   splitlinesR   (   RS   R   t
   prev_startR   R   R   t	   backslashR   Rb   Ra   R   RH   (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   explicit_line_join  s&    	#'
c         c  s   d   } t  } t } d } d } x | D] \ } } }	 }
 } | t j k rR q( n  d | k sj d | k r | t j k r t } q( | | |  r | r | r | | |  r |	 d f Vn  | d k } t  } | } | } q( Wd S(   s	  
    Avoid breaks before binary operators.

    The preferred place to break around a binary operator is after the
    operator, not before it.

    W503: (width == 0\n + height == 0)
    W503: (width == 0\n and height == 0)

    Okay: (width == 0 +\n height == 0)
    Okay: foo(\n    -x)
    Okay: foo(x\n    [])
    Okay: x = '''\n''' + ''
    Okay: foo(x,\n    -y)
    Okay: foo(x,  # comment\n    -y)
    Okay: var = (1 &\n       ~2)
    Okay: var = (1 /\n       -2)
    Okay: var = (1 +\n       -1 +\n       -2)
    c         S  s%   |  t  j k s | d k o$ | d k S(   Nt   andt   ors   ()[]{},:.;@=%~(   s   ands   or(   R   R   (   R   Rb   (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   is_binary_operatorF  s    s   
s   s&   W503 line break before binary operators   ([{,;N(   R   R   R   R   R   R   (   RS   R   R  t
   line_breakt   unary_contextt   previous_token_typet   previous_textR   Rb   Ra   R   RH   (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   break_around_binary_operator2  s&    	'	
c         c  s   | o t  j |   } | r | j d  p7 | j d  } | j d  d k } d | r^ d n d | } | d k r~ d	 } nE d
 } | d k r | p | d k o | } | d | r d n d 7} | j d  d | | | f f Vn  d S(   sX  Comparison to singletons should use "is" or "is not".

    Comparisons to singletons like None should always be done
    with "is" or "is not", never the equality operators.

    Okay: if arg is not None:
    E711: if arg != None:
    E711: if None == arg:
    E712: if arg == True:
    E712: if False == arg:

    Also, beware of writing if x when you really mean if x is not None --
    e.g. when testing whether a variable or argument that defaults to None was
    set to some other value.  The other value might have a type (such as a
    container) that could be false in a boolean context!
    i   i   i   s   ==s   'if cond is %s:'t    s   not R   t   E711t   E712R   R   s    or 'if %scond:'s    %s comparison to %s should be %sN(   s   None(   t   COMPARE_SINGLETON_REGEXR   R-   Ra   (   RS   RG   R,   t	   singletont   samet   msgRd   t   nonzero(    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   comparison_to_singletonc  s    	c         c  sY   t  j |   } | rU | j d  } | j d  d k rG | d f VqU | d f Vn  d S(   sG  Negative comparison should be done using "not in" and "is not".

    Okay: if x not in y:\n    pass
    Okay: assert (X in Y or X is Z)
    Okay: if not (X in Y):\n    pass
    Okay: zz = x is not y
    E713: Z = not X in Y
    E713: if not X.B in Y:\n    pass
    E714: if not X is Y:\n    pass
    E714: Z = not X.B is Y
    i   i   t   ins+   E713 test for membership should be 'not in's0   E714 test for object identity should be 'is not'N(   t   COMPARE_NEGATIVE_REGEXR   Ra   R-   (   RS   R,   Rm   (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   comparison_negative  s    c         c  se   t  j |   } | ra | ra | j d  } | rM t |  rM | t k rM d S| j   d f Vn  d S(   s  Object type comparisons should always use isinstance().

    Do not compare types directly.

    Okay: if isinstance(obj, int):
    E721: if type(obj) is type(1):

    When checking if an object is a string, keep in mind that it might be a
    unicode string too! In Python 2.3, str and unicode have a common base
    class, basestring, so you can do:

    Okay: if isinstance(obj, basestring):
    Okay: if type(a1) is type(b1):
    i   Ns-   E721 do not compare types, use 'isinstance()'(   t   COMPARE_TYPE_REGEXR   R-   R   t
   SINGLETONSRa   (   RS   RG   R,   t   inst(    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   comparison_type  s    c         c  sF   | r
 d St  j d  } | j |   } | rB | j   d f Vn  d S(   s   When catching exceptions, mention specific exceptions whenever possible.

    Okay: except Exception:
    Okay: except BaseException:
    E722: except:
    Ns
   except\s*:s   E722 do not use bare except'(   R   t   compileR,   Ra   (   RS   RG   t   regexR,   (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   bare_except  s    c         c  s2  d } | d \ } } } } } x| d D] \ } }	 }
 } } d } } | t j k r d |	 k r | | k r | } | } q n  | d k r |	 | k r |	 } |
 } q n  | d
 k r |	 | k r |
 d |	 f Vq n  | d k r|	 | k r|
 d |	 f Vqn  | r| d | f Vn  |	 } |
 } q* Wd S(   s  Never use the characters 'l', 'O', or 'I' as variable names.

    In some fonts, these characters are indistinguishable from the numerals
    one and zero. When tempted to use 'l', use 'L' instead.

    Okay: L = 0
    Okay: o = 123
    Okay: i = 42
    E741: l = 0
    E741: O = 123
    E741: I = 42

    Variables can be bound in several other contexts, including class and
    function definitions, 'global' and 'nonlocal' statements, exception
    handlers, and 'with' statements.

    Okay: except AttributeError as o:
    Okay: with lock as L:
    E741: except AttributeError as O:
    E741: with lock as l:
    E741: global I
    E741: nonlocal l
    E742: class I(object):
    E743: def l(x):
    t   lt   Ot   Ii    i   R   t   ast   globalt   nonlocalR)   s$   E742 ambiguous class definition '%s'R    s'   E743 ambiguous function definition '%s's!   E741 ambiguous variable name '%s'N(   R  R  R  (   s   ass   globalR  (   R   R   R   (   RS   R   t   idents_to_avoidR   R   R   R   R   R   Rb   Ra   R   RH   t   identRm   (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   ambiguous_identifier  s,     
c         c  s4   |  j  d  } | d k r0 | r0 | d f Vn  d S(   s   The {}.has_key() method is removed in Python 3: use the 'in' operator.

    Okay: if "alph" in d:\n    print d["alph"]
    W601: assert d.has_key('alph')
    s	   .has_key(is'   W601 .has_key() is deprecated, use 'in'N(   Rk   (   RS   RG   Rm   (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   python_3000_has_key  s    c         c  sA   t  j |   } | r= t j |   r= | j   d d f Vn  d S(   s   When raising an exception, use "raise ValueError('message')".

    The older form is removed in Python 3.

    Okay: raise DummyError("Message")
    W602: raise DummyError, "Message"
    i   s)   W602 deprecated form of raising exceptionN(   t   RAISE_COMMA_REGEXR,   t   RERAISE_COMMA_REGEXR   (   RS   R,   (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   python_3000_raise_comma   s    c         c  s-   |  j  d  } | d k r) | d f Vn  d S(   s   New code should always use != instead of <>.

    The older syntax is removed in Python 3.

    Okay: if a != 'no':
    W603: if a <> 'no':
    s   <>is!   W603 '<>' is deprecated, use '!='N(   Rk   (   RS   Rm   (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   python_3000_not_equal  s    c         c  s-   |  j  d  } | d k r) | d f Vn  d S(   sf   Use repr() instead of backticks in Python 3.

    Okay: val = repr(1 + 2)
    W604: val = `1 + 2`
    t   `is+   W604 backticks are deprecated, use 'repr()'N(   Rk   (   RS   Rm   (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   python_3000_backticks  s    i   c         C  s&   t  |  d   } | j   SWd QXd S(   s   Read the source code.t   rUN(   t   opent	   readlines(   t   filenamet   f(    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyR,  ,  s    s   [a-zA-Z_]\w*$c      	   C  s   ys t  |  d  ^ } t j | j  \ } } t | | d t } g  | D] } | j |  ^ qI | j   SWd QXWn? t t	 t
 f k
 r t  |  d d  } | j   SWd QXn Xd S(   s   Read the source code.t   rbt   line_bufferingNt   encodings   latin-1(   R+  R   t   detect_encodingt   readlineR   R   RA   R,  t   LookupErrort   SyntaxErrorRD   (   R-  R.  t   codingR;   RH   (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyR,  4  s    4c           C  s   t  t j j d d j   S(   s   Read the value from stdin.t   errorst   ignore(   R   t   syst   stdint   buffert   read(    (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   stdin_get_valueA  s    s   # no(?:qa|pep8)\bc         C  s|   d |  k r& t  |   t  |  j    Sd } xI |  D]A } | d k rZ | d d d } q3 | d k rs | d 7} q3 Pq3 W| S(   s   Return the amount of indentation.

    Tabs are expanded to the next multiple of 8.

    >>> expand_indent('    ')
    4
    >>> expand_indent('\t')
    8
    >>> expand_indent('       \t')
    8
    >>> expand_indent('        \t')
    16
    s   	i    i   R   i   (   R8   RR   (   RH   t   resultR3   (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyRQ   H  s    c         C  sj   |  j  |  d  d } t |   d } |  d d k rN | d 7} | d 8} n  |  |  d | | |  | S(	   s   Replace contents with 'xxx' to prevent syntax matching.

    >>> mute_string('"abc"')
    '"xxx"'
    >>> mute_string("'''abc'''")
    "'''xxx'''"
    >>> mute_string("r'abc'")
    "r'xxx'"
    ii   is   """s   '''i   t   x(   s   """s   '''(   R5   R8   (   Rb   Ra   R   (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   mute_stringc  s    
t   .c         C  sk  i  } d } } x|  j   D] } | rL | d  d k r | d 8} q q n  | d  d k r t j |  } g  | j   D] } t | p d  ^ qx \ }	 } | | j t |	 |	 |   q | d  d k r | d j d d  d	 } | d
  d k r| d
 } n  t	   | | <q q Wt
 g  | j   D]< \ } }
 |
 r(t | |  r(t j j | |  |
 f ^ q( S(   s&   Return a dictionary of matching lines.i   R   i   s   @@ t   1s   +++i   s   	i    i   s   b/N(   R   R   t
   HUNK_REGEXR,   Rg   t   intt   updateRt   RB   t   setR   t   itemst   filename_matcht   ost   patht   join(   t   difft   patternst   parentt   rvRJ  R   RH   t
   hunk_matcht   gR   t   rows(    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   parse_udiffw  s&    
1!c         C  s   |  s
 g  St  |  t  r |  Sg  } xi |  j d  D]X } | j   } d | k ru t j j t j j | |   } n  | j | j	 d   q3 W| S(   sQ   Parse a comma-separated list of paths.

    Return a list of absolute paths.
    R\   R   (
   t
   isinstanceR   RB   RP   RI  RJ  t   abspathRK  R   R7   (   t   valueRN  t   pathsRJ  (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   normalize_paths  s    $c           s$   | s
 | St    f d   | D  S(   s{   Check if patterns contains a pattern that matches filename.

    If patterns is unspecified, this always returns True.
    c         3  s   |  ] } t    |  Vq d  S(   N(   R   (   R   t   pattern(   R-  (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pys	   <genexpr>  s    (   R   (   R-  RM  R	   (    (   R-  s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyRH    s    c         C  s4   x- |  D]% } | | k r | | c d 7<q q Wd S(   s^   Adds one to the counts of each appearance of characters in s,
        for characters in countsi   N(    (   R   R   R3   (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyR     s    c         C  s0   |  d t  k p/ |  d |  d d j   d k S(   Ni    i   i   i   s   \
(   R   RR   (   t   token(    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   _is_eol_token  s    c         C  s1   | |   p0 |  d t  j k o0 |  d |  d k S(   Ni    i   i   (   R   R   (   RZ  t
   _eol_token(    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyR[    s    R/   RS   t   treec         C  sb   t  j d k rM g  t j |   j j   D]! } | j | j k r( | j ^ q( St j	 |   d Sd  S(   Ni   i    (   i   i   (
   R9  t   version_infot   inspectt	   signaturet
   parameterst   valuest   kindt   POSITIONAL_OR_KEYWORDt   namet
   getargspec(   t   functiont	   parameter(    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   _get_parameters  s
    c         C  s   d   } t  j |   r~ t |   } | r | d d
 k r | d	 k ra t j |  j pX d  } n  | |  | d | |  q nG t  j |   r t |  j  d  d d g k r | |  d | d	  q n  d	 S(   s   Register a new check object.c         S  sS   |  t  | k r2 t  | |  d j | p+ g   n | p> d g | f t  | |  <d  S(   Ni    R  (   t   _checkst   extend(   t   checkRc  t   codest   args(    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt
   _add_check  s    "i    R/   RS   R  i   t   selfR]  N(   s   physical_lines   logical_line(	   R_  t
   isfunctionRi  R   t   ERRORCODE_REGEXt   findallt   __doc__t   isclasst   __init__(   Rl  Rm  Ro  Rn  (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   register_check  s    	c          C  sC   t  j t  }  x- t  j |  t  j  D] \ } } t |  q% Wd S(   sw   Register all globally visible functions.

    The first argument name is either 'physical_line' or 'logical_line'.
    N(   R_  t	   getmoduleRw  t
   getmembersRq  (   t   modRe  Rg  (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   init_checks_registry  s    "t   Checkerc           B  s   e  Z d  Z d d d d d  Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d   Z d	   Z d
   Z d   Z d d d  Z RS(   s;   Load a Python source file, tokenize it, check coding style.c   	      K  s  | d  k r t |  j } n | s+ t  d  |  _ | j |  _ | j |  _ | j	 |  _
 | j |  _ t |  _ | j |  _ | j |  _ | |  _ i  |  _ | d  k r d |  _ | p g  |  _ n | d k r d |  _ t   j t  |  _ nt | d  k rVy t |  |  _ Wq_t k
 rRt j   d  \ } } d | j | f |  _ g  |  _ q_Xn	 | |  _ |  j rt |  j d d  } | d k r| d k r|  j d d |  j d <q|  j d d	  d
 k r|  j d d	 |  j d <qqn  | p| j |  _ |  j j |  _ t |  _ d  S(   NR:  R   i   s   %s: %si    i   i  i   i   s   ﻿(   i   i  (    R   t
   StyleGuidet   optionsR   t	   _io_errort   physical_checkst   _physical_checkst   logical_checkst   _logical_checkst
   ast_checkst   _ast_checksRE   R   RF   R   R   R-  t   _checker_statesR;   R=  R   R   R,  t   IOErrorR9  t   exc_infot   __name__t   ordt   reportR   t   report_errorRG   (	   Rp  R-  R;   R~  R  t   kwargst   exc_typet   exct   ord0(    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyRv    sJ    								!c         C  s   t  j   d  \ } } t | j  d k r] | j d } t |  d k rc | d d !} qc n d } |  j | d | d p} d d | j | j d f |  j  d S(   s   Check if the syntax is valid.i   i   i   i    s   E901 %s: %sN(   i   i    (   R9  R  R8   Rn  R  R  t   report_invalid_syntax(   Rp  R  R  R2   (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyR    s    c         C  sh   |  j  |  j k r d S|  j |  j  } |  j  d 7_  |  j d k rd | d  t k rd | d |  _ n  | S(   s(   Get the next line from the input buffer.R  i   i    N(   R<   R=   R;   R0   R   Ru   (   Rp  RH   (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyR3  )  s    c         C  s7   g  } x$ | D] } | j  t |  |   q W| |   S(   s   Run a check plugin.(   R   t   getattr(   Rp  Rl  t   argument_namest	   argumentsRe  (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt	   run_check3  s    c         C  s+   d | k r' |  j  j | i   |  _ n  d S(   s5   Prepare custom state for the specific checker plugin.R   N(   R  t
   setdefaultR   (   Rp  Re  R  (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   init_checker_state:  s    c         C  s   | |  _  x |  j D] \ } } } |  j | |  |  j | |  } | d k	 r | \ } } |  j |  j | | |  | d  d k r | d |  _ q q q Wd S(   s,   Run all physical checks on a raw input line.i   t   E101i    N(   R/   R  R  R  R   R  R<   R0   (   Rp  RH   Re  Rl  R  R>  R2   Rb   (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   check_physical?  s    	c         C  s  g  } g  } d } d } } } xT|  j D]I\ } } }	 }
 } | t k rQ q* n  | si d |	 f g } n  | t j k r | j |  q* n  | t j k r t |  } n  | r7|	 \ } } | | k r|  j | d | d } | d k s| d k r4| d k r4d | } q4q7| | k r7| | | !| } q7n  | j |  | t	 |  7} | j | |
 f  |
 \ } } q* Wd j
 |  |  _ | ot d j
 |   |  _ | S(	   s!   Build a logical line from tokens.i    i   R\   s   {[(s   }])R   R  N(   R   R   t   SKIP_TOKENSR   R   R   R   R@  R;   R8   RK  RS   RG   (   Rp  t   logicalt   commentsRI   t   prev_rowt   prev_colt   mappingR   Rb   Ra   R   RH   t	   start_rowt	   start_colR   (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   build_tokens_lineK  s<    c         C  s  |  j  j   |  j   } | s# d S| d d \ } } |  j | d } t | |   |  _ |  j |  j k  r| |  j |  _ n  |  j d k r |  j	 d  j
   GHn  x |  j D] \ } } } |  j d k r d | GHn  |  j | |  x |  j | |  p d D] \ } }	 t | t  s^x$ | D] \ }
 } | |
 k rPqqW| d | d | |
 f } n  |  j | d | d |	 |  q Wq W|  j	 r|  j |  _ |  j	 |  _ |  j s|  j	 |  _ qn  d |  _ g  |  _ d S(	   s:   Build a line from tokens and run all logical checks on it.Ni    i   i   iP   i   s      (    (   R  t   increment_logical_lineR  R;   RQ   RU   RV   RT   R   RS   R7   R  R  R  RT  t   tupleR  RY   RW   RX   R   (   Rp  R  R  R  t
   start_lineRe  Rl  R  R2   Rb   t   token_offsetRm   (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   check_logicall  s:    %&			c   
      C  s   y% t  d j |  j  d d t  } Wn! t t t f k
 rH |  j   SXx |  j D] \ } } } | | |  j	  } x[ | j
   D]M \ } } } }	 |  j s t |  j | d  r |  j | | | |	  q q WqS Wd S(   s,   Build the file's AST and run all AST checks.R  t   execi   N(   R  RK  R;   t   PyCF_ONLY_ASTt
   ValueErrorR5  t	   TypeErrorR  R  R-  t   runRG   R  (
   Rp  R]  Re  t   clsR   t   checkert   linenoR2   Rb   Rl  (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt	   check_ast  s    %"c         c  s   |  j  r) |  j d d d |  j  t  n  t j |  j  } y_ xX | D]P } | d d |  j k rf d S| d o} t | d  |  _ |  j |  | VqE WWn$ t	 t j
 f k
 r |  j   n Xd S(   s=   Tokenize the file, run physical line checks and yield tokens.i   i    s   E902 %si   Ni   (   R  R  R,  R   t   generate_tokensR3  R=   RG   t   maybe_check_physicalR5  t
   TokenErrorR  (   Rp  t   tokengenRZ  (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyR    s    	 c         C  s   t  |  r  |  j | d  n | d t j k r d | d k r t | d  rW d St |  _ | d d |  _ x? | d j d  d  D]& } |  j | d  |  j d 7_ q Wt	 |  _ n  d S(   s@   If appropriate (based on token), check current physical line(s).i   i    s   
i   Ni   i(
   R[  R  R   R   RG   R   RF   R<   RB   R   (   Rp  RZ  RH   (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyR    s    #	i    c         C  s  |  j  j |  j |  j | |  t |  j  |  _ |  j rG |  j   n  d |  _ d |  _
 d |  _ |  _ d |  _ d |  _ g  |  _ d |  _ |  _ d } x|  j   D]} |  j j |  | d d !\ } } |  j d k ra| d d | d d k r$d | d d pd | d d f } n d | d d } d | d d | t j | d | f GHn  | t j k r| d	 k r| d 7} q| d
 k r| d 8} qq | s | t k r| t j k r|  j   d |  _ qt |  j  d k r|  j d 7_ |  j d =q|  j   qt r| t j k rt |  j  d k rt |  } | j d  | d <| d d | d d t | d  f | d <t |  g |  _ |  j   qqq q W|  j r|  j |  j d  |  j   n  |  j  j    S(   s!   Run all checks on the input file.i    R  i   i   s   [%s:%s]i   s   l.%ss   l.%s	%s	%s	%rs   ([{s   }])s   
iN(!   R  t	   init_fileR-  R;   R8   R=   R  R  R<   R   R0   RU   RY   RW   RX   R   RT   RV   R  R   R   R   t   tok_nameR   R   R  t   COMMENT_WITH_NLR   R   R7   R  R  t   get_file_results(   Rp  t   expectedt   line_offsetR   RZ  R   Rb   Rm   (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt	   check_all  s\    						)(
.	N(   R  t
   __module__Rt  R   Rv  R  R3  R  R  R  R  R  R  R  R  R  (    (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyR|    s   *		
				!	"			t
   BaseReportc           B  s   e  Z d  Z e Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d   Z d d	  Z d d
  Z d d  Z d   Z RS(   s"   Collect the results of the checks.c         C  sO   | j  |  _ | j |  _ d |  _ d |  _ t j |  j d  |  _ i  |  _	 d  S(   Ni    (
   t   benchmark_keyst   _benchmark_keyst   ignore_codet   _ignore_codet   elapsedt   total_errorsR   t   fromkeyst   counterst   messages(   Rp  R~  (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyRv    s    		c         C  s   t  j    |  _ d S(   s   Start the timer.N(   t   timet   _start_time(   Rp  (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyRa     s    c         C  s   t  j    |  j |  _ d S(   s   Stop the timer.N(   R  R  R  (   Rp  (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   stop  s    c         C  sc   | |  _  | |  _ | p d |  _ | |  _ d |  _ |  j d c d 7<|  j d c t |  7<d S(   s   Signal a new file.i    R   i   s   physical linesN(    (   R-  R;   R  R  t   file_errorsR  R8   (   Rp  R-  R;   R  R  (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyR    s    				c         C  s   |  j  d c d 7<d S(   s   Signal a new logical line.s   logical linesi   N(   R  (   Rp  (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyR    s    c         C  s   | d  } |  j  |  r d S| |  j k rB |  j | c d 7<n d |  j | <| d |  j | <| |  j k rs d S|  j r |  j r |  j GHn  |  j d 7_ |  j d 7_ | S(   s&   Report an error, according to options.i   Ni   i   (   R  R  R  R  t   print_filenameR  R-  R  (   Rp  R<   R2   Rb   Rl  Rd   (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyR   !  s    
c         C  s   |  j  S(   s6   Return the count of errors and warnings for this file.(   R  (   Rp  (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyR  4  s    R  c         C  s6   t  g  |  j D]" } | j |  r |  j | ^ q  S(   s.   Return the total count of errors and warnings.(   t   sumR  RM   R  (   Rp  t   prefixt   key(    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt	   get_count8  s    c         C  sJ   g  t  |  j  D]6 } | j |  r d |  j | | |  j | f ^ q S(   s
  Get statistics for message codes that start with the prefix.

        prefix='' matches all errors and warnings
        prefix='E' matches all errors
        prefix='W' matches all warnings
        prefix='E4' matches all errors that have to do with imports
        s
   %-7s %s %s(   t   sortedR  RM   R  (   Rp  R  R  (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   get_statistics=  s    c         C  s#   x |  j  |  D] } | GHq Wd S(   s9   Print overall statistics (number of errors and warnings).N(   R  (   Rp  R  RH   (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   print_statisticsH  s    c         C  s]   d |  j  d f GH|  j  rY x; |  j D]- } d |  j | |  j  | |  j | f GHq% Wn  d S(   s   Print benchmark numbers.s	   %-7.2f %ss   seconds elapseds   %-7d %s per second (%d total)N(   R  R  R  (   Rp  R  (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   print_benchmarkM  s    	(   R  R  Rt  R   R  Rv  Ra   R  R  R  R   R  R  R  R  R  (    (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyR    s   					
			t
   FileReportc           B  s   e  Z d  Z e Z RS(   s?   Collect the results of the checks and print only the filenames.(   R  R  Rt  R   R  (    (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyR  W  s   t   StandardReportc           B  s2   e  Z d  Z d   Z d   Z d   Z d   Z RS(   s,   Collect and print the results of the checks.c         C  s_   t  t |   j |  t j | j j   | j  |  _ | j |  _	 | j
 |  _ | j |  _ d  S(   N(   t   superR  Rv  t   REPORT_FORMATR   t   formatt   lowert   _fmtt   repeatt   _repeatt   show_sourcet   _show_sourcet	   show_pep8t
   _show_pep8(   Rp  R~  (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyRv  `  s    c         C  s(   g  |  _  t t |   j | | | |  S(   s   Signal a new file.(   t   _deferred_printR  R  R  (   Rp  R-  R;   R  R  (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyR  h  s    	c         C  sp   t  t |   j | | | |  } | rl |  j | d k sC |  j rl |  j j | | | | d | j f  n  | S(   s&   Report an error, according to options.i   i   (   R  R  R   R  R  R  R   Rt  (   Rp  R<   R2   Rb   Rl  Rd   (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyR   n  s    "	 c         C  s  |  j  j   x |  j  D] \ } } } } } |  j i |  j d 6|  j | d 6| d d 6| d 6| d 6GH|  j r | t |  j  k r d } n |  j | d } | j   GHt	 j
 d d	 | |   d
 GHn  |  j r | r d | j   GHn  t j j   q W|  j S(   s<   Print the result and return the overall count for this file.RJ  R   i   t   colRd   Rb   R  s   \SR   R   s       (   R  t   sortR  R-  R  R  R8   R;   R7   R   t   subR  RP   R9  t   stdoutt   flushR  (   Rp  R<   R2   Rd   Rb   t   docRH   (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyR  w  s     	
		(   R  R  Rt  Rv  R  R   R  (    (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyR  ]  s
   				t
   DiffReportc           B  s    e  Z d  Z d   Z d   Z RS(   s9   Collect and print the results for the changed lines only.c         C  s&   t  t |   j |  | j |  _ d  S(   N(   R  R  Rv  t   selected_linest	   _selected(   Rp  R~  (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyRv    s    c         C  s9   | |  j  |  j k r d  St t |   j | | | |  S(   N(   R  R-  R  R  R   (   Rp  R<   R2   Rb   Rl  (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyR     s    (   R  R  Rt  Rv  R   (    (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyR    s   	R}  c           B  sh   e  Z d  Z d   Z d
 d  Z d
 d  Z d
 d
 d d  Z d   Z d
 d  Z	 d   Z
 d	   Z RS(   s-   Initialize a PEP-8 instance with few options.c   	      O  s  | j  d t  |  _ | j  d t  } | j  d t  } | j  d d   } t | |   } | rf d  n | j d d   } t | | | |  \ } |  _ | r | j	 j
 |  d | k r | d |  _ q n  |  j |  _ | |  _ | j s| j r t n t | _ n  t | j pd  | _ | j p=| j p=| j p=| j rbt rbt t j d   | _ n! | j rqd n t | j  | _ t | _ |  j | _ |  j d  | _ |  j d	  | _ |  j d
  | _ |  j    d  S(   Nt   checker_classt
   parse_argvt   config_filet   parserRW  R\   R  R/   RS   R]  (    (   R  (!   R   R|  R  R   R   R   R   t   process_optionsRW  t   __dict__RE  t
   input_filet   runnerR~  t   reportert   quietR  R  R  t   selectR8  R   t   doctestt   DEFAULT_IGNORERB   t   BENCHMARK_KEYSR  R  t
   get_checksR  R  R  t   init_report(	   Rp  Rn  R  R  R  R  t   options_dictt   arglistR~  (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyRv    s6    		!
c         C  s+   | p |  j  j |  j   |  j  _ |  j  j S(   s   Initialize the report instance.(   R~  R  R  (   Rp  R  (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyR    s    !c         C  s   | d k r |  j } n  |  j j } |  j } | j   yS xL | D]D } t j j |  ri |  j	 |  qA |  j
 |  sA | |  qA qA WWn t k
 r d GHn X| j   | S(   s   Run all checks on the paths.s   ... stoppedN(   R   RW  R~  R  R  Ra   RI  RJ  t   isdirt	   input_dirt   excludedt   KeyboardInterruptR  (   Rp  RW  R  R  RJ  (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   check_files  s    	
	
i    c         C  sL   |  j  j r d | GHn  |  j | d | d |  j  } | j d | d |  S(   s'   Run all checks on a Python source file.s   checking %sR;   R~  R  R  (   R~  R   R  R  (   Rp  R-  R;   R  R  t   fchecker(    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyR    s
    c         C  s)  | j  d  } |  j |  r" d S|  j j j } |  j j } |  j j } |  j } x t j	 |  D] \ } } } | r d | GHn  | d c d 7<x6 t
 |  D]( }	 |  j |	 |  r | j |	  q q WxR t
 |  D]D }
 t |
 |  r |  j |
 |  r | t j j | |
   q q Wqb Wd S(   s9   Check all files in this directory and all subdirectories.R   i    s
   directory R   i   N(   R7   R  R~  R  R  R   R-  R  RI  t   walkR  t   removeRH  RJ  RK  (   Rp  t   dirnameR  R   t   filepatternsR  t   roott   dirsR   t   subdirR-  (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyR    s$    	c         C  s~   |  j  j s t St j j |  } t | |  j  j  r; t S| rY t j j | |  } n  t j j	 |  } t | |  j  j  S(   s|   Check if the file should be excluded.

        Check if 'options.exclude' contains a pattern that matches filename.
        (
   R~  t   excludeR   RI  RJ  t   basenameRH  R   RK  RU  (   Rp  R-  RN  R  (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyR    s    c           sa   t     d k  r8 t   f d   |  j j D  r8 t S  j |  j j  o`   j |  j j  S(   s   Check if the error code should be ignored.

        If 'options.select' contains a prefix of the error code,
        return False.  Else, if 'options.ignore' contains a prefix of
        the error code, return True.
        i   c         3  s   |  ] } | j     Vq d  S(   N(   RM   (   R   R   (   Rd   (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pys	   <genexpr>  s   (   R8   R   R~  R  R   RM   R8  (   Rp  Rd   (    (   Rd   s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyR    s
    !c           su   g  } xb t  | j   D]P \ } } | \ } } t   f d   | D  r | j | j | | f  q q Wt |  S(   s   Get all the checks for this category.

        Find all globally visible functions where the first argument name
        starts with argument_name and which contain selected tests.
        c         3  s%   |  ] } | o   j  |  Vq d  S(   N(   R  (   R   Rd   (   Rp  (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pys	   <genexpr>#  s    (   Rj  RG  R   R   R  R  (   Rp  t   argument_namet   checksRl  t   attrsRm  Rn  (    (   Rp  s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyR    s     N(   R  R  Rt  Rv  R   R  R  R  R  R  R  R  (    (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyR}    s   	%		c         C  s  t  d |  d | d d  } d d d d d	 d
 d d d d d d d g | _ | j d d d d d d d d | j d d d d d d d d | j d d d t d d d d | j d  d d! d" d# d d$ | j d% d& d' d t d d( | j d) d& d' d d* d d+ | j d, d& d- d d. d d/ | j d0 d& d- d d. d d1 t | j d2 d d d d3 | j d4 d d d d5 | j d6 d d d d7 | j d8 d d d d9 | j d: d; d< d& d= d t d d> | j d? d d d d@ | j dA d& d d d d dB | j dC d d d dD | j dE  } t j	 j
 t  r| j dF d& dG d dH | j dI d d d dJ n  | j dK d d d dL | S(M   s"   Create the parser for the program.t   progt   versiont   usages   %prog [options] input ...R
  R-  R  R8  s   max-line-lengths   hang-closingRv   R  R  s	   show-pep8s   show-sourcet
   statisticsR   s   -vs	   --verboseR	   i    t   actiont   helps(   print status messages, or debug with -vvs   -qs   --quiets+   report only file names, or nothing with -qqs   -rs   --repeatt
   store_trues1   (obsolete) show all occurrences of the same errors   --firstt   store_falset   destR  s#   show first occurrence of each errors	   --excludet   metavarRM  s[   exclude files or directories which match these comma separated patterns (default: %default)s
   --filenames   *.pysj   when parsing directories, only check filenames matching these comma separated patterns (default: %default)s   --selectR7  R  s&   select errors and warnings (e.g. E,W6)s   --ignores2   skip errors and warnings (e.g. E4,W) (default: %s)s   --show-sources   show source code for each errors   --show-pep8s3   show text of PEP 8 for each error (implies --first)s   --statisticss   count errors and warningss   --countsg   print total number of errors and warnings to standard error and set exit code to 1 if total is not nulls   --max-line-lengtht   typeRD  t   ns3   set maximum allowed line length (default: %default)s   --hang-closingsN   hang closing bracket instead of matching indentation of opening bracket's lines   --formats.   set the error format [default|pylint|<custom>]s   --diffsS   report changes only within line number ranges in the unified diff received on STDINs   Testing Optionss   --testsuitet   dirs   run regression tests from dirs	   --doctests   run doctest on myselfs   --benchmarks   measure processing speed(   R   t   config_optionst
   add_optionR   t   DEFAULT_EXCLUDER  t   MAX_LINE_LENGTHt   add_option_groupRI  RJ  t   existst   TESTSUITE_PATH(   R  R  R  R-   (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt
   get_parser(  s`    	
c           s  t    } |  j } t j } t rX t j j t  rX |  j rH d t GHn  | j t  n  | oy t j j	 t j j
 |     } x` | r | j   f d   t D  r   } |  j r d   GHn  Pn  t j j    \   } q W| r t j j |  r |  j rd | GHn  | j |  n  d } | j | j  rD| j } n% | j d  rid } t j d  n  | rt g  | j D]! }	 |	 j |	 j p|	 j f ^ q| }
 | j g   \ } } x| j |  D] } | j d d  | j k rd	 | GHqn  |  j d
 k r(d | | j | |  f GHn  | j d d  } |
 | } | d k re| j | |  } nQ | d k r| j | |  } n0 | j | |  } | d k rt | |  } n  t | | |  qW| j | d | \ }  } n  t  |  _! |  _" |  S(   sw  Read and parse configurations.

    If a config file is specified on the command line with the "--config"
    option, then only it is used for configuration.

    Otherwise, the user configuration (~/.config/pycodestyle) and any local
    configurations in the current directory or above will be merged together
    (in that order) using the read method of ConfigParser.
    s   user configuration: %sc         3  s$   |  ] } t  j j   |  Vq d  S(   N(   RI  RJ  RK  (   R   t   fn(   RN  (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pys	   <genexpr>}  s    s   local configuration: in %ss   cli configuration: %st   pep8s0   [pep8] section is deprecated. Use [pycodestyle].t   _R   s     unknown option '%s' ignoredi   s	     %s = %sRD  Rv   R  R  R
  Rb  N(   s   ints   count(   s
   store_trues   store_false(#   R   t   configRI  t   curdirt   USER_CONFIGRJ  t   isfileR   R<  RU  t   commonprefixt   PROJECT_CONFIGRB   R   t   has_sectionR  t   warningst   warnR   t   option_listR  R  R  t
   parse_argsR~  R   R  R   t   getintt
   getbooleanRX  t   setattrR   R  R   (   R~  Rn  R  R  R'  t   cli_conft	   local_dirt   tailt   pycodestyle_sectiont   oR0  t   new_optionsR   t   optt   normalized_optt   opt_typeRV  (    (   RN  s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   read_configf  sb    
				(			1	
c         C  s  | s t    } n  | j d  sq | j d d d | j d j | j  f } | j d d d d | d	 d
 n  |  r | r g  }  n  | j |   \ } } d | _	 | j
 d t  r | j | j  n | j
 d t  s[| r%| r%| j s	t d   t D  rd g } q%| j d  n  t | | |  |  } | oR| j d k oRt | _	 n  t | j  | _ t | j  | _ t | j  | _ t | j  | _ | j rt | _	 t   } t | | j | d  | _ t | j  } n  | | f S(   s   Process options passed either via arglist or via command line args.

    Passing in the ``config_file`` parameter allows other tools, such as flake8
    to specify their own options to be processed in pycodestyle.
    s   --configt   Configurationt   descriptions   The project options are read from the [%s] section of the tox.ini file or the setup.cfg file located in any parent folder of the path(s) being processed.  Allowed options are: %s.s   , R  RJ  R	   R  s   user config file locationR   R  c         s  s!   |  ] } t  j j |  Vq d  S(   N(   RI  RJ  R!  (   R   Re  (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pys	   <genexpr>  s   RA  s   input not specifiedi   i    N(    R#  t
   has_optionR   R  RK  R  R  R1  R   R  t   ensure_valueR   R   R   RL  R   R,  R   R>  R  R  t   _parse_multi_optionsR-  RX  R
  R  R8  R  R=  RS  R  R  (   R  R  R  R  R-   R~  Rn  R:  (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyR    s@    
		!			R\   c         C  s@   |  r8 g  |  j  |  D] } | j   r | j   ^ q S|  Sd S(   sg   Split and strip and discard empties.

    Turns the following:

    A,
    B,

    into ["A", "B"]
    N(   RB   RP   (   R~  t   split_tokenR9  (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyRC    s    
2c          C  s!  d d l  }  y |  j  |  j d    Wn t k
 r9 n Xt d t  } | j } | j sd | j r d d l m	 } | |  } n | j
   } | j r | j   n  | j r | j   n  | j r | j r | j   n  | j r| j rt j j t | j  d  n  t j d  n  d S(   s.   Parse options and run checks on Python source.iNc         S  s   t  j d  S(   Ni   (   R9  t   exit(   t   signumt   frame(    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   <lambda>  s    R  (   t	   run_testss   
i   (   t   signalt   SIGPIPEt   AttributeErrorR}  R   R~  R  R   t   testsuite.supportRI  R  R  R  t	   benchmarkR  R  t   print_resultsR  Rv   R9  t   stderrt   writeR   RE  (   RJ  t   style_guideR~  RI  R  (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   _main  s*    					 t   __main__(   Rt  t
   __future__R    R_  R   RI  R   R9  R  R   R.  R   t   optparseR   t   configparserR   t   ioR   t   ImportErrort   ConfigParsert   __version__R  R  t   platformRJ  t
   expanduserR)  RK  t   getenvR   R,  R  t   __file__R"  R  R  R  t	   frozensetR  t   kwlistR   R   R   t   unionR   R   Ru   R   R   t   INDENTt   DEDENTR  R   t
   ERRORTOKENR   R  R  R+   R$  R%  Rr  RO   R_   R   R
  R  R  Rf   R   R   RC  R   RN   R  R   R   R  R   t   sendR  R4   R6   R:   R?   RK   RT   Re   Rj   Rn   Rx   R}   R   R   R   R   R   R   R   R   R   R   R   R  R  R  R  R  R"  R#  R&  R'  R)  R^  R,  R,   R   R:  R<  R=  R   R  R   RG   RQ   R@  RS  R(  RX  R   RH  R   R[  Rj  Ri  Rw  R{  t   objectR|  R  R  R  R  R}  R#  R>  R   R  RC  RS  R  (    (    (    s0   /tmp/pip-build-EndXZ2/pycodestyle/pycodestyle.pyt   <module>0   s  	
!
!'		(					&	>	 						 		\		2	)		8	<	'	1	"				4										
				
	
 Z7>	K	2	"