ó
„¾^Yc           @@  sÞ   d  Z  d d l m Z y d d l m Z Wn e k
 r= n Xe j ƒ  d d l Z d d l Z d d l	 Z d d l
 m Z e g  d% D] Z e j ƒ  d d d! … ^ q† ƒ Z d" „  Z e ƒ  d# e j j f d$ „  ƒ  YZ d S(&   s8   Plugin built-in to Flake8 to treat pyflakes as a plugin.i    (   t   absolute_import(   t   demandimportN(   t   utilss   F401 UnusedImports   F402 ImportShadowedByLoopVars   F403 ImportStarUseds   F404 LateFutureImports   F405 ImportStarUsages   F406 ImportStarNotPermitteds   F407 FutureFeatureNotDefineds!   F601 MultiValueRepeatedKeyLiterals"   F602 MultiValueRepeatedKeyVariables*   F621 TooManyExpressionsInStarredAssignments   F622 TwoStarredExpressionss   F631 AssertTuples   F701 BreakOutsideLoops   F702 ContinueOutsideLoops   F703 ContinueInFinallys   F704 YieldOutsideFunctions"   F705 ReturnWithArgsInsideGenerators   F706 ReturnOutsideFunctions   F707 DefaultExceptNotLasts   F721 DoctestSyntaxErrors   F811 RedefinedWhileUnuseds   F812 RedefinedInListComps   F821 UndefinedNames   F822 UndefinedExports   F823 UndefinedLocals   F831 DuplicateArguments   F841 UnusedVariableiÿÿÿÿc          C@  sh   xa t  t j ƒ j ƒ  D]J \ }  } |  d j ƒ  r | j r d t j |  d ƒ | j f | _ q q Wd S(   s%   Add error codes to Pyflakes messages.i    s   %s %st   F999N(	   t   varst   pyflakest   messagest   itemst   isuppert   messaget   FLAKE8_PYFLAKES_CODESt   gett
   flake8_msg(   t   namet   obj(    (    s7   /tmp/pip-build-EndXZ2/flake8/flake8/plugins/pyflakes.pyt   patch_pyflakes3   s    "t   FlakesCheckerc           B@  s_   e  Z d  Z d Z e j Z e Z g  Z	 g  Z
 d „  Z e d „  ƒ Z e d „  ƒ Z d „  Z RS(   s=   Subclass the Pyflakes checker to conform with the flake8 API.R   c         C@  sô   t  j | ƒ d } |  j } g  |  j D]' } | d k r& | j | ƒ r& | ^ q& } | rb t } n  xl |  j D]a } | d k rl | j | ƒ rl t } g  | D] } | j | ƒ rš | ^ qš } | rÍ t } qÍ ql ql Wt t	 |  ƒ j
 | | d | ƒd S(   s=   Initialize the PyFlakes plugin with an AST tree and filename.i    t    t   withDoctestN(   R   t   normalize_pathst   with_doctestt   include_in_doctestt
   startswitht   Truet   exclude_from_doctestt   Falset   superR   t   __init__(   t   selft   treet   filenameR   t   includet   included_byt   excludet   overlaped_by(    (    s7   /tmp/pip-build-EndXZ2/flake8/flake8/plugins/pyflakes.pyR   H   s    	'	c         C@  s¶   | j  d d t d t d d ƒ| j  d d t d d	 d t d d
 ƒ| j  d d d d d d t d t d t d d d d ƒ| j  d d d d d d t d t d t d d d d ƒd S(   s:   Register options for PyFlakes on the Flake8 OptionManager.s
   --builtinst   parse_from_configt   comma_separated_listt   helps&   define more built-ins, comma separateds
   --doctestst   defaultt   actiont
   store_trues   check syntax of the doctestss   --include-in-doctestR   t   destR   R   s    Run doctests only on these filest   typet   strings   --exclude-from-doctestR   s&   Skip these files when running doctestsN(   t
   add_optionR   R   (   t   clst   parser(    (    s7   /tmp/pip-build-EndXZ2/flake8/flake8/plugins/pyflakes.pyt   add_options]   s&    c         C@  s\  | j  r$ |  j j | j  ƒ |  _ n  | j |  _ g  } x_ | j D]T } | d k rX q@ n  | j t j d d f ƒ s‡ | j	 d | ƒ q@ | j	 | ƒ q@ Wt
 j | ƒ |  _ g  } x_ | j D]T } | d k rÒ qº n  | j t j d d f ƒ s| j	 d | ƒ qº | j	 | ƒ qº Wt
 j | ƒ |  _ t |  j ƒ j |  j ƒ } | rXt d | ƒ ‚ n  d S(   s0   Parse option values from Flake8's OptionManager.R   s   ./s   ~/s   "%s" was specified in both the include-in-doctest and exclude-from-doctest options. You are not allowed to specify it in both for doctesting.N(   t   builtinst   builtInst   uniont   doctestsR   R   R   t   ost   sept   appendR   R   R   t   sett   intersectiont
   ValueError(   R-   t   optionst   included_filest   included_filet   excluded_filest   excluded_filet   inc_exc(    (    s7   /tmp/pip-build-EndXZ2/flake8/flake8/plugins/pyflakes.pyt   parse_optionsx   s0    	c         c@  sK   xD |  j  D]9 } t | d d ƒ } | j | | j | j | j f Vq
 Wd S(   s   Run the plugin.t   coli    N(   R   t   getattrt   linenoR   t   message_argst	   __class__(   R   R	   RA   (    (    s7   /tmp/pip-build-EndXZ2/flake8/flake8/plugins/pyflakes.pyt   runœ   s    (   t   __name__t
   __module__t   __doc__R   R   t   __version__t   versionR   R   R   R   R   t   classmethodR/   R@   RF   (    (    (    s7   /tmp/pip-build-EndXZ2/flake8/flake8/plugins/pyflakes.pyR   ?   s   		$(   s   F401 UnusedImports   F402 ImportShadowedByLoopVars   F403 ImportStarUseds   F404 LateFutureImports   F405 ImportStarUsages   F406 ImportStarNotPermitteds   F407 FutureFeatureNotDefineds!   F601 MultiValueRepeatedKeyLiterals"   F602 MultiValueRepeatedKeyVariables*   F621 TooManyExpressionsInStarredAssignments   F622 TwoStarredExpressionss   F631 AssertTuples   F701 BreakOutsideLoops   F702 ContinueOutsideLoops   F703 ContinueInFinallys   F704 YieldOutsideFunctions"   F705 ReturnWithArgsInsideGenerators   F706 ReturnOutsideFunctions   F707 DefaultExceptNotLasts   F721 DoctestSyntaxErrors   F811 RedefinedWhileUnuseds   F812 RedefinedInListComps   F821 UndefinedNames   F822 UndefinedExports   F823 UndefinedLocals   F831 DuplicateArguments   F841 UnusedVariable(   RI   t
   __future__R    t	   mercurialR   t   ImportErrort   disableR4   R   t   pyflakes.checkert   flake8R   t   dictt   linet   splitR
   R   t   checkert   CheckerR   (    (    (    s7   /tmp/pip-build-EndXZ2/flake8/flake8/plugins/pyflakes.pyt   <module>   sR   
                          ,		