
'![c           @  sf  d  Z  d d l m Z d d l Z d d l Z d d l Z d d l Z y d d l Z Wn e k
 ro e	 Z n Xd 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 d d l m Z d d l m Z d d l m Z d d	 l m Z d d
 l m Z d d l m Z d d l m Z d d l m Z e j Z d   Z d   Z  d   Z! e j" d    Z# i d d d f d 6d d d f d 6d d d f d 6d d d f d  6d! d" d# f d$ 6d% d& d' f d( 6d) d* d+ f d, 6d- d. d/ f d0 6d1 d2 d3 f d4 6d5 d6 d7 f d8 6d9 d: d; i d< d= f g d> 6f d? 6d d@ dA f dB 6dC dD dE f dF 6dG dH dI f dJ 6Z$ e e	 k	 rdK e j% f dL     YZ& n  dM e j' e j( e j) e j* f dN     YZ+ dO   Z, dP   Z- dQ   Z. dR e/ f dS     YZ0 dT   Z1 e j" dU    Z2 dV e3 f dW     YZ4 dX   Z5 dY   Z6 e7 dZ k rbe4 e
 j8 d[  n  d S(\   s   %prog [options] modules_or_packages

  Check that module(s) satisfy a coding standard (and more !).

    %prog --help

  Display this help message and exit.

    %prog --help-msg <msg-id>[,<msg-id>]

  Display help messages about given message identifiers and exit.
i(   t   print_functionN(   t   version(   t   modutils(   t   checkers(   t
   interfaces(   t	   reporters(   t
   exceptions(   t   utils(   t   config(   t   nodesc         C  sI   |  j  |  j |  j |  j |  j |  j f } |  j |  j | |  j |  j	 f S(   N(
   t   abspatht   patht   modulet   objt   linet   columnt   msg_idt   symbolt   msgt
   confidence(   t   messaget   location(    (    s*   lib/python2.7/site-packages/pylint/lint.pyt   _get_new_argsP   s    c         C  s   t  j j t  j j |    } t  j j |  sE t  j j |  } n  x] t r t  j j t  j j | d   ss | S| } t  j j |  } | | k rH t  j	   SqH Wd  S(   Ns   __init__.py(   t   osR   t   realpatht
   expandusert   isdirt   dirnamet   Truet   existst   joint   getcwdt   None(   t   filepathR   t   old_dirname(    (    s*   lib/python2.7/site-packages/pylint/lint.pyt   _get_python_patha   s    	!c         C  s   i  } t  j   } x |  D] } | j d i   } | j |  xk t j |  D]Z \ } } | | k rs | | | <qN t | t  r | | j |  qN | | | | | <qN Wq W| | d <| S(   Nt   by_msg(   t   collectionst   Countert   popt   updatet   sixt	   iteritemst
   isinstancet   dict(   t   statst   mergedR$   t   statt   message_statst   keyt   item(    (    s*   lib/python2.7/site-packages/pylint/lint.pyt   _merge_statso   s    
c          c  sS   t  d k }  |  r) t j t  t j d <n  z	 d  VWd  |  rN t j j d  n  Xd  S(   Nt   __main__(   t   __name__t   syst   modulesR'   (   t	   mock_main(    (    s*   lib/python2.7/site-packages/pylint/lint.pyt   _patch_sysmodules   s    	s   %st   fatalso   Used when an error occurred preventing the analysis of a               module (unable to find it for instance).t   F0001s   %s: %ss   astroid-errors   Used when an unexpected error occurred while building the Astroid  representation. This is usually accompanied by a traceback. Please report such errors !t   F0002s   error while code parsing: %ss   parse-errorsl   Used when an exception occurred while building the Astroid representation which could be handled by astroid.t   F0010s0   Unable to run raw checkers on built-in module %ss   raw-checker-failedsR   Used to inform that a built-in module has not been checked using the raw checkers.t   I0001s#   Unable to consider inline option %rs   bad-inline-optionsU   Used when an inline option is either badly formatted or can't be used inside modules.t   I0010s   Locally disabling %s (%s)s   locally-disabledsE   Used when an inline option disables a message or a messages category.t   I0011s   Locally enabling %s (%s)s   locally-enabledsD   Used when an inline option enables a message or a messages category.t   I0012s   Ignoring entire files   file-ignoreds0   Used to inform that the file will not be checkedt   I0013s   Suppressed %s (from line %d)s   suppressed-messages   A message was triggered on a line, but suppressed explicitly by a disable= comment in the file. This message is not generated for messages that are ignored due to configuration settings.t   I0020s   Useless suppression of %ss   useless-suppressionsb   Reported when a message is explicitly disabled for a line or a block of code, but never triggered.t   I0021s+   Pragma "%s" is deprecated, use "%s" insteads   deprecated-pragmas   Some inline pylint options have been renamed or reworked, only the most recent form should be used. NOTE:skip-all is only available with pylint >= 0.26t   I0014s   deprecated-disable-allt	   old_namest   I0022s   syntax-errors0   Used when a syntax error is raised for a module.t   E0001s   Unrecognized file option %rs   unrecognized-inline-options2   Used when an unknown inline option is encountered.t   E0011s   Bad option value %rs   bad-option-values:   Used when a bad value for an inline option is encountered.t   E0012t   ChildLinterc           B  s   e  Z d    Z d   Z RS(   c         C  s   |  j  \ } } |  _ d |  j d <|  j j d d   |  _ |  j j d d   |  _ x t | j d  D]w } y$ |  j | d  } | j	 |  Wqe t
 k
 r } t d | d t j t | d t j | j	 i   qe Xqe Wd  S(	   Ni   t   jobst   python3_porting_modet   pluginst   STOPi    s0   internal error with sending report for module %st   file(   t   _argst   _configR'   R    t   _python3_porting_modet   _pluginst   itert   gett   _run_lintert   putt	   Exceptiont   printR6   t   stderr(   t   selft   tasks_queuet   results_queuet   file_or_modulet   resultt   ex(    (    s*   lib/python2.7/site-packages/pylint/lint.pyt   run   s    	c         C  s   t    } | j   |  j r/ | j |  j  n  | j |  j  | j t j    |  j	 rh | j
   n  | j |  g  | j j D] } t |  ^ q } | | j j | j | | j | j f S(   N(   t   PyLintert   load_default_pluginsRT   t   load_plugin_modulest   load_configuration_from_configRR   t   set_reporterR   t   CollectingReporterRS   RM   t   checkt   reportert   messagesR   t
   file_statet	   base_namet   current_nameR-   t
   msg_status(   R\   R_   t   lintert   mt   msgs(    (    s*   lib/python2.7/site-packages/pylint/lint.pyRW      s    	
		%(   R5   t
   __module__Rb   RW   (    (    (    s*   lib/python2.7/site-packages/pylint/lint.pyRK      s   	Rc   c           B  sy  e  Z d  Z e j f Z d Z d Z d Z e	 Z
 e d    Z d& d' f Z d( d) d* d) d  Z d	   Z d
   Z d   Z d   Z d   Z d) d) d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z e e  d   Z! d   Z" d   Z# d   Z$ d   Z% d   Z& d   Z' d) d   Z( d!   Z) d"   Z* d#   Z+ d$   Z, d%   Z- RS(+   s  lint Python modules using external checkers.

    This is the main checker controlling the other ones and the reports
    generation. It is itself both a raw checker and an astroid checker in order
    to:
    * handle message activation / deactivation at the module level
    * handle some basic but necessary stats'data (number of classes, methods...)

    IDE plugin developers: you may have to call
    `astroid.builder.MANAGER.astroid_cache.clear()` across runs if you want
    to ensure the latest code version is actually checked.
    t   masteri    c          C  s  d i d d 6d d 6d d 6dN d	 6d
 d 6f d i d d 6d d 6d d 6dO d	 6d d 6f d i t  d	 6d d 6d d 6d d 6d d 6f d i d d 6d d 6dP d	 6d d 6d d 6f d i d d	 6d d 6d d 6d d 6d  d! 6d" d 6f d# i t d	 6d d 6d d 6d$ d 6d  d! 6d% d 6f d& i d d 6d' d 6d  d! 6d d 6d( d	 6d) d 6f d* i t  d	 6d d 6d d 6d+ d 6d  d! 6d, d 6f d- i d. d 6d/ d 6d0 d	 6g  t j D] }  |  j ^ qd1 6d2 d! 6d3 d4 j d5   t j D  f d 6f d6 i d d 6d7 d 6d8 d 6d2 d! 6d9 d 6f d: i d d 6d7 d 6d; d 6d2 d! 6d< d 6f d= i d d 6d> d 6d  d! 6d? d 6f d@ i dA d 6dB d 6dC d 6d d	 6dD d 6f dE i d d 6dF d 6t d	 6t  dG 6dH d 6f dI i d d 6dJ d 6g  d	 6dK d 6f dL i d d 6dF d 6t  d	 6dM d 6f f S(Q   Nt   ignoret   csvt   types   <file>[,<file>...]t   metavart
   black_listt   destt   CVSt   defaultsP   Add files or directories to the blacklist. They should be base names, not paths.t   helps   ignore-patternst
   regexp_csvs   <pattern>[,<pattern>...]t   black_list_resw   Add files or directories matching the regex patterns to the blacklist. The regex matches against base names, not paths.t
   persistentt   yns   <y_or_n>i   t   levels,   Pickle collected data for later comparisons.s   load-pluginss	   <modules>su   List of plugins (as comma separated values of python modules names) to load, usually to register additional checkers.s   output-formatt   textt   strings   <format>t   ft   shortt   Reportst   groups   Set the output format. Available formats are text, parseable, colorized, json and msvs (visual studio).You can also give a reporter class, eg mypackage.mymodule.MyReporterClass.t   reportst   rs;   Tells whether to display a full report or only the messagest
   evaluations   <python_expression>sN   10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)s6  Python expression which should return a note less than 10 (10 is the highest note). You have access to the variables errors warning, statement which respectively contain the number of errors / warnings messages and the total number of statements analyzed. This is used by the global evaluation report (RP0004).t   scoret   ss   Activate the evaluation score.R   t   multiple_choices   <levels>t    t   choicess   Messages controls_   Only show warnings with the listed confidence levels. Leave empty to show all. Valid levels: %ss   , c         s  s   |  ] } | j  Vq d  S(   N(   t   name(   t   .0t   c(    (    s*   lib/python2.7/site-packages/pylint/lint.pys	   <genexpr>e  s    t   enables	   <msg ids>t   es0  Enable the message, report, category or checker with the given id(s). You can either give multiple identifier separated by comma (,) or put this option multiple time (only on the command line, not in the configuration file where it should appear only once). See also the "--disable" option for examples. t   disablet   ds`  Disable the message, report, category or checker with the given id(s). You can either give multiple identifiers separated by comma (,) or put this option multiple times (only on the command line, not in the configuration file where it should appear only once).You can also use "--disable=all" to disable everything first and then reenable specific checks. For example, if you want to run only the similarities checker, you can use "--disable=all --enable=similarities". If you want to run only the classes checker, but have no Warning level messages displayed, use"--disable=all --enable=classes --disable=W"s   msg-templates
   <template>s   Template used to display messages. This is a python new-style format string used to format the message information. See doc for all detailsRL   t   ints   <n-processes>t   js*   Use multiple processes to speed up Pylint.s   unsafe-load-any-extensions   <yn>t   hides   Allow loading of arbitrary C extensions. Extensions are imported into the active Python interpreter and may run arbitrary code.s   extension-pkg-whitelists   <pkg[,pkg]>s   A comma-separated list of package or module names from where C extensions may be loaded. Extensions are loading into the active Python interpreter and may run arbitrary codes   suggestion-modes   When enabled, pylint would attempt to guess common misconfiguration and emit user-friendly hints instead of false-positive error messages(   R{   (    (    (   R   t   FalseR   t   CONFIDENCE_LEVELSR   R   (   R   (    (    s*   lib/python2.7/site-packages/pylint/lint.pyt   make_options"  s    







 $





s   Messages controls%   Options controlling analysis messagesR   s2   Options related to output formatting and reportingc         C  s  t  j   |  _ d  |  _ d  |  _ i  |  _ t j t	  |  _
 i  |  _ t |  _ t  j   |  _ d  |  _ d  |  _ d  |  _ | |  _ | t j   |  _ | t j |  _ i |  j d 6|  j d 6|  _ i |  j d 6|  j d 6|  _ d t t t j f } t  j j  |   t  j! j  |   t" t |   j  d t# d | d | p>t$ j%  t& j' j  |   d	 d
 t( f d d t) f d d t* f f |  _+ |  j, |   t-   |  _. t |  _/ t |  _0 |  j1   | r|  j2 |  n  d  S(   NR   R   s   disable-msgs
   enable-msgs    %%prog %s, 
astroid %s
Python %st   usageR   t   config_filet   RP0001s   Messages by categoryt   RP0002s   % errors / warnings by modulet   RP0003t   Messages(3   R   t   MessagesStoret
   msgs_storeR    Rj   t   _reporter_namet
   _reportersR%   t   defaultdictt   listt	   _checkerst   _pragma_linenoR   t   _ignore_filet	   FileStateRl   Rn   t   current_fileR-   t   _external_optsRc   R   t   optionst   option_groupsR   R   t   _options_methodst   _bw_options_methodsR   t   astroid_versionR6   t   MessagesHandlerMixInt   __init__t   ReportsHandlerMixInt   supert   __doc__R   t   PYLINTRCR   t   BaseTokenCheckert   report_total_messages_statst   report_messages_by_module_statst   report_messages_statsR   t   register_checkert   sett   _dynamic_pluginsRS   t   _error_modet   load_provider_defaultsRg   (   R\   R   Rj   R   t   pylintrct   full_version(    (    s*   lib/python2.7/site-packages/pylint/lint.pyR     sR    									
		
c         C  s4   t  j |   t j |   |  j s0 |  j   n  d  S(   N(   R   t
   initializeR   Rj   t   _load_reporter(   R\   (    (    s*   lib/python2.7/site-packages/pylint/lint.pyRd     s    	c         C  sV   xO | D]G } | |  j  k r" q n  |  j  j |  t j |  } | j |   q Wd S(   s`   take a list of module names which are pylint plugins and load
        and register them
        N(   R   t   addR   t   load_module_from_namet   register(   R\   t   modnamest   modnameR   (    (    s*   lib/python2.7/site-packages/pylint/lint.pyRe     s    c         C  s   |  j  j   } | |  j k r8 |  j |  j |    nI y |  j   } Wn& t t f k
 rp t j |   n X|  j |    d  S(   N(	   R   t   lowerR   Rg   t   _load_reporter_classt   ImportErrort   AttributeErrorR   t   InvalidReporterError(   R\   R   t   reporter_class(    (    s*   lib/python2.7/site-packages/pylint/lint.pyR     s    c         C  sG   |  j  } t j t j |   } | j d  d } t | |  } | S(   Nt   .i(   R   R   R   t   get_module_partt   splitt   getattr(   R\   t   qnameR   t
   class_nameR   (    (    s*   lib/python2.7/site-packages/pylint/lint.pyR     s    	c         C  s   | |  _  |  | _ d S(   s5   set the reporter used to display messages and reportsN(   Rj   Rp   (   R\   Rj   (    (    s*   lib/python2.7/site-packages/pylint/lint.pyRg     s    	c         C  sV  | |  j  k s | |  j k r | ry |  j  | } WnE t k
 r| |  j | } t j d | | j d  d f t  n Xt j |  } t	 | t
 t f  r x+ | D] } | | d t q Wn
 | |  d Sn. | d k r| |  _ |  j r|  j   qn  y  t j j |  | | | |  Wn+ t j k
 rQt d | d t j n Xd S(	   s[   overridden from config.OptionsProviderMixin to handle some
        special options
        s"   %s is deprecated, replace it by %st   -i    t   ignore_unknownNs   output-formats(   option %s can't be read from config fileRP   (   R   R   t   KeyErrort   warningst   warnR   t   DeprecationWarningR   t
   _check_csvR+   R   t   tupleR   R   R   R   R   R   t
   set_optionR   t   UnsupportedActionRZ   R6   R[   (   R\   t   optnamet   valuet   actiont   optdictt   metht   _id(    (    s*   lib/python2.7/site-packages/pylint/lint.pyR   
  s4    
		c         C  s   | |  j  | j <d  S(   N(   R   R   (   R\   R   (    (    s*   lib/python2.7/site-packages/pylint/lint.pyt   register_reporter-  s    c         C  sW   t  |  j d d   } y | j | j |    Wn t k
 rE n X| j |   | S(   NR1   c         S  s   t  |  d d  S(   NR   R   (   R   (   t   x(    (    s*   lib/python2.7/site-packages/pylint/lint.pyt   <lambda>1  s    (   t   sortedt   _reportsR'   t   indext
   ValueErrort   append(   R\   R   (    (    s*   lib/python2.7/site-packages/pylint/lint.pyt   report_order0  s    c         C  s   | j  d k s t d   |  j | j j |  x0 | j D]% \ } } } |  j | | | |  q< W|  j |  t | d  r |  j	 j
 |  n  | j   t | d t  s |  j | j  n  d S(   so   register a new checker

        checker is an object implementing IRawChecker or / and IAstroidChecker
        i    s   checker priority can't be >= 0Rr   t   enabledN(   t   priorityt   AssertionErrorR   R   R   R   t   register_reportt   register_options_providert   hasattrR   t   register_messagest   load_defaultsR   R   R   (   R\   t   checkert   r_idt   r_titlet   r_cb(    (    s*   lib/python2.7/site-packages/pylint/lint.pyR   >  s    
c         C  su   xn t  j |  j j  D]W \ } } | d k rO x< | D] } |  j |  q5 Wq x | D] } |  j |  qV Wq Wd  S(   Nt   Et   F(   R   R   (   R)   R*   R   t   _msgs_by_categoryR   R   (   R\   t   msgcatt   msgidst   msgid(    (    s*   lib/python2.7/site-packages/pylint/lint.pyt   disable_noerror_messagesQ  s    "c         C  sH   xA t  j |  j  D]- } x$ | D] \ } } } |  j |  q  Wq Wd S(   s   disable all reportersN(   R)   t
   itervaluesR   t   disable_report(   R\   R   t	   report_idt   _(    (    s*   lib/python2.7/site-packages/pylint/lint.pyt   disable_reporters[  s    c         C  s   t  |  _ |  j   |  j d  |  j r |  j d  x6 |  j d  D]% } | j d  rF |  j |  qF qF W|  j } | j	 d d  r | j
 d d  } |  j d |  q n |  j d  |  j d t  |  j d t  |  j d	 t  d
 S(   s9   error mode: enable only errors; no reports, no persistentt   miscellaneoust   allt   python3R   s   MESSAGES CONTROLR   R   R   R   N(   R   R   R  R   RS   t   _checker_messagest
   startswithR   t   cfgfile_parsert
   has_optionRV   t   global_set_optionR   R   (   R\   R   t   config_parserR   (    (    s*   lib/python2.7/site-packages/pylint/lint.pyt
   error_modea  s     	
		c         C  s   |  j  d  |  j d  |  j rl xF |  j d  D]2 } | j d  rX |  j |  q3 |  j  |  q3 Wn  |  j } | j d d  r | j d d  } |  j d |  n  t	 |  _
 d S(   s8   Disable all other checkers and enable Python 3 warnings.R  R  R   s   MESSAGES CONTROLR   N(   R   R   R   R  R  R  R  RV   R  R   RS   (   R\   R   R  R   (    (    s*   lib/python2.7/site-packages/pylint/lint.pyRM   u  s    		c      
   C  s  d d h } x| D]\ } } } } } | t  j k r= q n  t j j |  } | d k ra q n  | j d  j   d k s | j d  j   d k r | j d  j   d k r |  j d d | d d	 d n  |  j d
 d | d t	 |  _
 d Sy% | j d  j d d  \ } }	 Wn@ t k
 r]|  j d d	 | j d  j   d | d q n X| j   } | |  j k s| |  j k ry |  j | }
 WnM t k
 r|  j | }
 |  j d d | d d	 | | j d d  f n Xx t j |	  D] } | | k r| d |  j | <n  yk | | f d k ru|  j d d | d d	 d |  j d
 d | d t	 |  _
 d S|
 | d | d  Wqt j k
 r|  j d d	 | d | d qXqWq |  j d d	 | d | d q Wd S(   s`   process tokens from the current module to search for module/block
        level options
        R   R   i   s   disable-alls	   skip-files   deprecated-pragmaR   i    t   argss   file-ignoredNt   =s   bad-inline-options   -msgR   R  s   disable=allR   s   bad-option-values   unrecognized-inline-option(   s   disable-alls	   skip-file(   R   R  (   s   disable=alls	   skip-file(   t   tokenizet   COMMENTR   t
   OPTION_RGXt   searchR    R   t   stript   add_messageR   R   R   R   R   R   R   t   replacet   _splitstripR   R   t   UnknownMessageError(   R\   t   tokenst   control_pragmast   tok_typet   contentt   startR  t   matcht   optR   R   R  (    (    s*   lib/python2.7/site-packages/pylint/lint.pyt   process_tokens  sV    
	%!	(c         C  sC   |  g g  t  j |  j  D]% } | D] } | |  k	 r# | ^ q# q S(   s'   return all available checkers as a list(   R)   R  R   (   R\   R   R   (    (    s*   lib/python2.7/site-packages/pylint/lint.pyt   get_checkers  s    c           s     j  j s   j   n    g } xl   j   d D]Z } t   f d   | j D  } | s} t   f d   | j D  r3 | j |  q3 q3 Wt | d t	 j
 d  d t } | S(   s9   return checkers needed for activated messages and reportsi   c         3  s$   |  ] }   j  |  r | Vq d  S(   N(   t   is_message_enabled(   R   R   (   R\   (    s*   lib/python2.7/site-packages/pylint/lint.pys	   <genexpr>  s    c         3  s"   |  ] }   j  | d   Vq d S(   i    N(   t   report_is_enabled(   R   R   (   R\   (    s*   lib/python2.7/site-packages/pylint/lint.pys	   <genexpr>  s    R1   R   t   reverse(   R   R   R	  R'  R   Rr   t   anyR   R   t   operatort
   attrgetterR   (   R\   t   neededcheckersR   Rk   (    (   R\   s*   lib/python2.7/site-packages/pylint/lint.pyt   prepare_checkers  s    			c         C  s   | r
 t  S| j d  S(   s  Returns whether or not a module should be checked.

        This implementation returns True for all python source file, indicating
        that all files should be linted.

        Subclasses may override this method to indicate that modules satisfying
        certain conditions should not be linted.

        :param str modname: The name of the module to be checked.
        :param str path: The full path to the source code of the module.
        :param bool is_argument: Whetter the file is an argument to pylint or not.
                                 Files which respect this property are always
                                 checked, since the user requested it explicitly.
        :returns: True if the module should be checked.
        :rtype: bool
        s   .py(   R   t   endswith(   R   R   t   is_argument(    (    s*   lib/python2.7/site-packages/pylint/lint.pyt   should_analyze_file  s    c         C  s   x3 |  j  j D]% } | j   s t |  j | j <q q Wt | t t f  sW | f } n  |  j	 j
 d k ry |  j |  n t    |  j |  Wd QXd S(   sW   main checking entry: check a list of files or modules from their
        name.
        i   N(   R   Rk   t   may_be_emittedR   t   _msgs_stateR  R+   R   R   R   RL   t	   _do_checkR9   t   _parallel_check(   R\   t   files_or_modulesR   (    (    s*   lib/python2.7/site-packages/pylint/lint.pyRi     s    
c         C  s   t  j   } d h } | j d   |  j D  xt t j |  j  D]` } xW | j   D]I \ } } } | j d  ry qU n  | | k rU t	 j
 | |  | | <qU qU WqB W|  j | d <|  j | d <| S(   Ns	   long-helpc         s  s   |  ] \ } } | Vq d  S(   N(    (   R   t   opt_nameR  (    (    s*   lib/python2.7/site-packages/pylint/lint.pys	   <genexpr>  s    t
   deprecatedRM   RN   (   R%   t   OrderedDictR(   R   R)   R  t   _all_optionst   options_and_valuesRV   R   t   _format_option_valueRS   R   (   R\   t   child_configt   filter_optionst   opt_providersR   R   t   val(    (    s*   lib/python2.7/site-packages/pylint/lint.pyt   _get_jobs_config  s    	c         c  s  |  j    } g  } t j   } | j   } | j   } |  j |  } xX t t |  j j t	 |    D]5 } t
 d | | | f  }	 |	 j   | j |	  qg Wx( | D]  }
 |
 d } | j | g  q Wt } xf | D]^ } y | j   } Wn@ t k
 r0} t d d t j t | d t j t } Pn X| Vq Wx' t |  j j  D] } | j d  qMWx | D] } | j   qkW| rt d d t j t j d  n  d  S(   NR  R   s8   internal error while receiving results from child linterRP   RO   s$   Error occurred, stopping the linter.i    (   RB  t   multiprocessingt   Managert   Queuet   expand_filest   ranget   minR   RL   t   lenRK   R#  R   RX   R   RV   RY   RZ   R6   R[   R   R   t   exit(   R\   R7  R>  t   childrent   managerR]   R^   t   expanded_filesR  t   child_lintert   files_or_moduleR   t   failedR`   Ra   t   child(    (    s*   lib/python2.7/site-packages/pylint/lint.pyt   _parallel_task  s@    (

	
	c         C  s  |  j    g  } d  } x |  j |  D] } | s8 q& n  | \ } |  j _ } } } } x: | D]2 }	 t j |	   }	 |  j |  |  j j	 |	  q] W| j
 |  |  j | O_ q& Wt |  |  _ | |  _ x/ |  j   D]! }
 |
 |  k	 r |  j |
 _ q q Wd  S(   N(   t   openR    RR  Rl   Rm   R   t   Messaget   set_current_moduleRj   t   handle_messageR   Ro   R3   R-   Rn   R'  (   R\   R7  t	   all_statsR   R`   R  Rk   R-   Ro   R   R   (    (    s*   lib/python2.7/site-packages/pylint/lint.pyR6  C  s$    
	c         C  s
  t  j |   } |  j   } g  | D]- } t j | t j  r" | |  k	 r" | ^ q" } g  | D]! } t j | t j  r\ | ^ q\ } x= | D]5 } | j   t j | t j  r | j	 |  q q Wx|  j
 |  D] } | d | d | d }	 }
 } |  j |	 |
 d | sq n  |  j |	 |
  |  j |
 |	  } | d  k rKq n  t  j | d  |  _ t |  _ | j |  _ |  j | | | |  |  j j |  j  } x- | D]% \ } } } |  j | | d  |  qWq W| j |  j d <x t |  D] } | j   qWd  S(   NR   R   t   isargR1  t   basenamet	   statement(   R   t   PyLintASTWalkerR/  R   t
   implementst   ITokenCheckert   IRawCheckerRS  t   IAstroidCheckert   add_checkerRF  R2  RU  t   get_astR    R   Rl   R   R   RP   R   t   check_astroid_modulet"   iter_spurious_suppression_messagesR   R  t   nbstatementsR-   t   reversedt   close(   R\   R7  t   walkerR   R   t   tokencheckerst   rawcheckersR   t   descrR   R!   t   is_argt   ast_nodet   spurious_messagesR  R   R  (    (    s*   lib/python2.7/site-packages/pylint/lint.pyR5  e  s:    !
 	c         C  s   t  j | |  j j |  j j  \ } } x~ | D]v } | d } } | d } |  j |  | d k r t | d  j t j	   t j
 d  } n  |  j | d | q. W| S(   sH   get modules and errors from a list of modules and handle errors
        t   modR1   R:   Ra   R   R  (   R   t   expand_modulesR   Ry   R   RU  t   strR  R   R   t   sepR  (   R\   R7   R`   t   errorst   errorR   R   R1   (    (    s*   lib/python2.7/site-packages/pylint/lint.pyRF    s    
,c         C  s   | r | d k r d S|  j j | |  | |  _ | p< | |  _ i  |  j d | <d |  j d | d <x/ t j t j	  D] } d |  j d | | <q{ Wd S(   sY   set the name of the currently analyzed module and
        init statistics for it
        Nt	   by_modulei    RZ  (
   R    Rj   t   on_set_current_moduleRn   R   R-   R)   R  R   t	   MSG_TYPES(   R\   R   R!   t   msg_cat(    (    s*   lib/python2.7/site-packages/pylint/lint.pyRU    s    	c         C  s   y t  j | | d t SWn t j k
 rc } |  j d d t | j d d  d t | j  nm t j	 k
 r } |  j d d | nE t
 k
 r } d d	 l } | j   |  j d
 d | j | f n Xd	 S(   s.   return a ast(roid) representation for a modulet   sources   syntax-errorR   t   linenoi    R  s   parse-erroriNs   astroid-error(   t   MANAGERt   ast_from_fileR   t   astroidt   AstroidSyntaxErrorR  R   Rs  Rp  t   AstroidBuildingExceptionRY   t	   tracebackt	   print_exct	   __class__(   R\   R!   R   Ra   R  (    (    s*   lib/python2.7/site-packages/pylint/lint.pyRa    s    
c         C  s   y t  j |  } WnB t j k
 rW } |  j d d | j d d d | j d d SX| j sz |  j d d | j nl |  j	 |  |  j
 r t S|  j j |  j |  x | D] } | j |  q Wx | D] } | j	 |  q W| j |  t S(   s/   Check a module from its astroid representation.s   syntax-errorR   i   i    R  s   raw-checker-failedN(   R   t   tokenize_moduleR  t
   TokenErrorR  R  R    t   pure_pythonR   R&  R   R   Rl   t   collect_block_linesR   t   process_modulet   walkR   (   R\   Rl  Rg  Ri  Rh  R  Ra   R   (    (    s*   lib/python2.7/site-packages/pylint/lint.pyRb    s"    +		c         C  sj   i i  d 6i  d 6|  _  |  j j t _ t j j |  j j  x' t j	 t
 j  D] } d |  j  | <qO Wd S(   s   initialize countersRt  R$   i    N(   R-   R   t   unsafe_load_any_extensionRz  t   always_load_extensionst   extension_package_whitelistR(   t   extension_pkg_whitelistR)   R  R   Rv  (   R\   Rw  (    (    s*   lib/python2.7/site-packages/pylint/lint.pyRS    s    
	c         C  s   |  j  j t j    |  j j d k	 r t j |  j j  } |  j  j	 |  j
 |  |  j j rw |  j |  j
 |  } n t j   } |  j j r |  j  j |  n  |  j   |  j j r t j |  j
 |  j j  q n |  j  j	 |  j
 i   d S(   s   close the whole package /module, it's time to make reports !

        if persistent run, pickle results for later comparison
        N(   Rj   t   display_messagest   report_nodest   SectionRl   Rm   R    R   t   load_resultst   on_closeR-   R   t   make_reportst   display_reportst   _report_evaluationR   t   save_results(   R\   t   previous_statst   sect(    (    s*   lib/python2.7/site-packages/pylint/lint.pyt   generate_reports  s    
c         C  s   t  j |  j j  } |  j d d k r, d S|  j  j } y t | i  |  j  } Wn t k
 rp } d | } nN X| |  j d <d | } | j d  } | d k	 r | d | | | f 7} n  |  j  j
 r t j |  } |  j j |  n  d S(   s!   make the global evaluation reportRZ  i    Ns&   An exception occurred while rating: %st   global_notes#   Your code has been rated at %.2f/10s    (previous run: %.2f/10, %+.2f)(   R   R  Rl   Rm   R-   R   t   evalRY   RV   R    R   R  t   EvaluationSectionRj   R  (   R\   R  R   t   noteRa   R   t   pnoteR  (    (    s*   lib/python2.7/site-packages/pylint/lint.pyR    s     
(   s   Messages controls%   Options controlling analysis messages(   R   s2   Options related to output formatting and reporting(    N(    (.   R5   Rs   R   R   R]  t   __implements__R   R   R   t   MSGSRr   t   staticmethodR   R   R    R   Rd   Re   R   R   Rg   R   R   R   R   R  R	  R  RM   R&  R'  R/  R   R2  Ri   RB  RR  R6  R5  RF  RU  Ra  Rb  RS  R  R  (    (    (    s*   lib/python2.7/site-packages/pylint/lint.pyRc   
  sR   		2					#				
				7					.	"	*					c         C  sT   d d d d g } | t  j | | d  7} |  j t j d	 | d
 d d d   d S(   s#   make total errors / warnings reportRw   t   numbert   previoust
   differencet
   conventiont   refactort   warningRs  RK  t   colsi   t   rheadersi   N(   R  R  R  Rs  (   R   t   table_lines_from_statsR   R  t   Table(   R  R-   R  t   lines(    (    s*   lib/python2.7/site-packages/pylint/lint.pyR     s
     
c         C  s   | d s t  j    n  t g  t j | d  D]' \ } } | j d  s0 | | f ^ q0  } | j   d } x* | D]" \ } } | | t |  f 7} qw W|  j t	 j
 d | d d d d	   d
 S(   s   make messages type reportR$   t   Is
   message idt   occurrencesRK  R  i   R  i   N(   s
   message idR  (   R   t   EmptyReportErrorR   R)   R*   R  R*  Rp  R   R  R  (   R  R-   R  R   R   t   in_orderR  (    (    s*   lib/python2.7/site-packages/pylint/lint.pyR   "  s    
$
c         C  s  t  | d  d k r% t j    n  t j t  } x d D]w } | | } xd t j | d  D]O } | d | | } | d k r d } n t | d	  | } | | | | <q_ Wq; Wg  }	 xI t j	 |  D]8 \ } }
 |	 j
 |
 d |
 d |
 d |
 d | f  q W|	 j   |	 j   d
 d d d d g } xe |	 D]] } t d   | d  D  r^q8n  | j
 | d  x# | d  D] } | j
 d |  qzWq8Wt  |  d k rt j    n  |  j
 t j d | d d d d   d S(   s(   make errors / warnings by modules reportRt  i   R:   Rs  R  R  R  i    id   R   c         s  s   |  ] } | d  k Vq d S(   i    N(    (   R   t   entry(    (    s*   lib/python2.7/site-packages/pylint/lint.pys	   <genexpr>K  s    is   %.2fi   RK  R  R  N(   R:   Rs  R  R  R  (   RI  R   R  R%   R   R,   R)   t   iterkeyst   floatR*   R   t   sortR*  R  R  R  (   R  R-   R  t   by_modt   m_typet   totalR   t	   mod_totalt   percentt   sorted_resultt   mod_infoR  R   RA  (    (    s*   lib/python2.7/site-packages/pylint/lint.pyR   0  s<    
	

t   ArgumentPreprocessingErrorc           B  s   e  Z d  Z RS(   s8   Raised if an error occurs during argument preprocessing.(   R5   Rs   R   (    (    (    s*   lib/python2.7/site-packages/pylint/lint.pyR  X  s   c   	      C  sd  d } xW| t  |   k  r_|  | } | j d  rRy  | d j d d  \ } } Wn" t k
 rx | d d	 } } n Xy | | \ } } Wn t k
 r | d 7} q\X|  | =| r| d	 k r| t  |   k s |  | j d  rd | } t |   n  |  | } |  | =n, | rB| d	 k	 rBd | } t |   n  | | |  q	 | d 7} q	 Wd	 S(
   s   look for some options (keys of <search_for>) which have to be processed
    before others

    values of <search_for> are callback functions to call when the option is
    found
    i    s   --i   R  i   R   s   Option %s expects a values!   Option %s doesn't expects a valueN(   RI  R  R   R   R    R   R  (	   R  t
   search_fort   it   argt   optionRA  t   cbt   takeargR   (    (    s*   lib/python2.7/site-packages/pylint/lint.pyt   preprocess_options\  s0    
 %



c         c  s   t  t j  } g  } x9 |  D]1 } t |  } | | k r@ q q | j |  q W| d g t j t j (z	 d VWd | t j (Xd S(   sB  Prepare sys.path for running the linter checks.

    Within this context, each of the given arguments is importable.
    Paths are added to sys.path in corresponding order to the arguments.
    We avoid adding duplicate directories to sys.path.
    `sys.path` is reset to its original value upon exiting this context.
    R   N(   R   R6   R   R#   R   (   R  t   origt   changesR  R   (    (    s*   lib/python2.7/site-packages/pylint/lint.pyt   fix_import_path  s    		t   Runc           B  sz   e  Z d  Z e Z d Z d e d  Z d   Z	 d   Z
 d   Z d   Z d   Z d	   Z d
   Z d   Z d   Z RS(   sE   helper class to use as main for pylint :

    run(*sys.argv[1:])
    t   CommandssR   Options which are actually commands. Options in this group are mutually exclusive.c   	      C  s  d  |  _ g  |  _ y> t | i t t f d 6|  j t f d 6|  j t f d 6 Wn3 t k
 r } t	 | d t
 j t
 j d  n X|  j d i d d 6d   d 6d	 d
 6d d 6d d 6f d i d d 6d   d 6d	 d
 6d d 6d d 6d d 6f d i d d 6d	 d
 6d d 6|  j d 6d d 6d d 6f d i d d 6d d 6|  j d 6d d 6d d 6d d 6f d i d d 6t d 6d d 6d d 6d d 6f d i d d 6d d 6|  j d 6d d 6d d 6d d 6f d i d d 6|  j d 6d d 6d d 6f d  i d d 6|  j d 6d d 6d! d 6t d" 6f d# i d d 6|  j d 6d$ d% 6d& d 6f d' i d d 6|  j d 6d( d 6f f
 d) |  j d* |  j |  _ } | j   | j |  j  | j d+ t j d d | j d, d- d d | j d. d/ d d | j d0  | j d1  | j   | j  } | j! d2 d  rDt d t" j# | j$ d2 d    n  | j! d2 d  rt" j% | j$ d2 d   } | j |  n  | j&   | r| j' |  n  y | j( |  } Wn1 t) k
 r} | j* d3 k rd | _* n    n X| st	 | j+    t
 j d  n  | j j, d4 k  rMt	 d5 | j j, d t
 j t
 j d  n  | j j, d k sq| j j, d4 k rt- d  k rt	 d6 d t
 j | j. d7 d  q| j j, d4 k rt- j/   | j _, qn  t0 |   | j1 |  | j2   Wd  QX| rt
 j |  j j3  n  d  S(8   Ns	   init-hookt   rcfiles   load-pluginsRP   i    t   callbackR   c          W  s   d S(   Ni   (    (   R  (    (    s*   lib/python2.7/site-packages/pylint/lint.pyR     s    R   Rw   s   <file>Rx   s   Specify a configuration file.R}   c          W  s   d S(   Ni   (    (   R  (    (    s*   lib/python2.7/site-packages/pylint/lint.pyR     s    s   <code>i   R   sR   Python code to execute, usually for sys.path manipulation such as pygtk.require().s   help-msgs   <msg-id>R  R   sq   Display a help message for the given message id and exit. The value may be a comma separated list of message ids.s	   list-msgss   Generate pylint's messages.s   list-conf-levelss   full-documentations%   Generate pylint's full documentation.s   generate-rcfiles   Generate a sample configuration file according to the current configuration. You can put other options before this one to get them in the generated configuration.s   generate-mans   Generate pylint's man page.R   s   errors-onlyR   R   s   In error mode, checkers without error messages are disabled and for others, only the ERROR messages are displayed, and no reports are done by defaultt   py3ksz   In Python 3 porting mode, all checkers will be disabled and only messages emitted by the porting checker will be displayedR   R   s   Environment variablest   Outputs5  Using the default text output, the message format is :                          
                                                                                
        MESSAGE_TYPE: LINE_NUM:[OBJECT:] MESSAGE                                
                                                                                
There are 5 kind of message types :                                             
    * (C) convention, for programming standard violation                        
    * (R) refactor, for bad code smell                                          
    * (W) warning, for python specific problems                                 
    * (E) error, for probable bugs in the code                                  
    * (F) fatal, if an error occurred which prevented pylint from doing further
processing.
s   Output status codes[  Pylint should leave with following status code:                                 
    * 0 if everything went fine                                                 
    * 1 if a fatal message was issued                                           
    * 2 if an error message was issued                                          
    * 4 if a warning message was issued                                         
    * 8 if a refactor message was issued                                        
    * 16 if a convention message was issued                                     
    * 32 on usage error                                                         
                                                                                
status 1 to 16 will be bit-ORed so you can know which different categories has
been issued by analysing pylint output status code
R  s   c-extension-no-membert   MASTERi   i    s)   Jobs number (%d) should be greater than 0s>   Multiprocessing library is missing, fallback to single processRL   (4   R    t   _rcfileRT   R  t   cb_init_hookR   t   cb_set_rcfilet   cb_add_pluginsR  RZ   R6   R[   RJ  t   LinterClasst   cb_help_messaget   cb_list_messagest   cb_list_confidence_levelst   cb_full_documentationt   cb_generate_configt   cb_generate_manpaget   cb_error_modet   cb_python3_porting_modeR   Rp   Rd   Re   t   add_help_sectionR   t   ENV_HELPR   R   t   read_config_fileR  R  R   t   _unquoteRV   R  t   load_config_fileRg   t   load_command_line_configurationt
   SystemExitt   codeR}   RL   RC  R   t	   cpu_countR  Ri   R  Ro   (	   R\   R  Rj   RJ  Ra   Rp   R  RN   t   exc(    (    s*   lib/python2.7/site-packages/pylint/lint.pyR     s    			












		
	
$	
c         C  s   | |  _  d S(   s>   callback for option preprocessing (i.e. before option parsing)N(   R  (   R\   R   R   (    (    s*   lib/python2.7/site-packages/pylint/lint.pyR  H  s    c         C  s   |  j  j t j |   d S(   s>   callback for option preprocessing (i.e. before option parsing)N(   RT   t   extendR   R  (   R\   R   R   (    (    s*   lib/python2.7/site-packages/pylint/lint.pyR  L  s    c         O  s   |  j  j   d S(   s   error mode:
        * disable all but error messages
        * disable the 'miscellaneous' checker which can be safely deactivated in
          debug
        * disable reports
        * do not save execution information
        N(   Rp   R  (   R\   R  t   kwargs(    (    s*   lib/python2.7/site-packages/pylint/lint.pyR  P  s    c         O  s$   |  j  j d d  t j d  d S(   s0   optik callback for sample config file generationt   skipsectionst   COMMANDSi    N(   R  (   Rp   t   generate_configR6   RJ  (   R\   R  R  (    (    s*   lib/python2.7/site-packages/pylint/lint.pyR  Z  s    c         O  s1   d d l  m } |  j j |  t j d  d S(   s0   optik callback for sample config file generationi(   t   __pkginfo__i    N(   t   pylintR  Rp   t   generate_manpageR6   RJ  (   R\   R  R  R  (    (    s*   lib/python2.7/site-packages/pylint/lint.pyR  _  s    c         C  s-   |  j  j j t j |   t j d  d S(   s@   optik callback for printing some help about a particular messagei    N(   Rp   R   t   help_messageR   R  R6   RJ  (   R\   R  R   R   t   parser(    (    s*   lib/python2.7/site-packages/pylint/lint.pyR  e  s    c         C  s   |  j  j   t j d  d S(   s.   optik callback for printing full documentationi    N(   Rp   t   print_full_documentationR6   RJ  (   R\   R  R   R   R  (    (    s*   lib/python2.7/site-packages/pylint/lint.pyR  j  s    c         C  s!   |  j  j j   t j d  d S(   s.   optik callback for printing available messagesi    N(   Rp   R   t   list_messagesR6   RJ  (   R\   R  R   R   R  (    (    s*   lib/python2.7/site-packages/pylint/lint.pyR  o  s    c         O  s   |  j  j   d S(   s*   Activate only the python3 porting checker.N(   Rp   RM   (   R\   R  R  (    (    s*   lib/python2.7/site-packages/pylint/lint.pyR  t  s    (   R  sR   Options which are actually commands. Options in this group are mutually exclusive.(   (   R  sR   Options which are actually commands. Options in this group are mutually exclusive.N(   R5   Rs   R   Rc   R  R   R    R   R   R  R  R  R  R  R  R  R  R  (    (    (    s*   lib/python2.7/site-packages/pylint/lint.pyR    s    			
					c         C  s3   x t  j D] } t d |  q
 Wt j d  d  S(   Ns	   %-18s: %si    (   R   R   RZ   R6   RJ  (   R  R   R   R  R   (    (    s*   lib/python2.7/site-packages/pylint/lint.pyR  y  s    c         B  s   | d Ud S(   s0   exec arbitrary code to set sys.path for instanceN(    (   R   R   (    (    s*   lib/python2.7/site-packages/pylint/lint.pyR  ~  s    R4   i   (9   R   t
   __future__R    R%   t
   contextlibR,  R   RC  R   R    R6   R  R   R)   R|  t   astroid.__pkginfo__R   R   R   R  R   R   R   R   R   R   t   pylint.__pkginfo__t   pylint.reporters.ureportsR	   R  Rz  R   R#   R3   t   contextmanagerR9   R  t   ProcessRK   t   OptionsManagerMixInR   R   R   Rc   R   R   R   RY   R  R  R  t   objectR  R  R  R5   t   argv(    (    (    s*   lib/python2.7/site-packages/pylint/lint.pyt   <module>/   s   
				











0	   			(	#		