ó
'![c           @  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 m Z d d l	 m
 Z
 d d l m Z d d l m Z d d	 d
 d g Z d Z d Z d Z i d d 6d d 6d d 6d d 6d d 6d d 6d d 6Z i	 d d 6d d 6d d  6d! d" 6d# d$ 6d% d& 6d' d( 6d) d* 6d+ d, 6Z d d d- „ Z d d d. „ Z d/ e
 f d0 „  ƒ  YZ d1 e f d2 „  ƒ  YZ d3 e f d4 „  ƒ  YZ d5 e f d6 „  ƒ  YZ d7 „  Z d S(8   sv   Plain text reporters:

:text: the default one grouping messages by module
:colorized: an ANSI colorized text reporter
iÿÿÿÿ(   t   print_functionN(   t	   IReporter(   t   BaseReporter(   t   utils(   t
   TextWritert    t   =t   -t   .s   [t   ms   [0mt   0t   resett   1t   boldt   3t   italict   4t	   underlinet   5t   blinkt   7t   inverset   9t   striket   30t   blackt   31t   redt   32t   greent   33t   yellowt   34t   bluet   35t   magentat   36t   cyant   37t   whitec         C  s¨   g  } | r@ t  j | ƒ } x" | D] } | j t | ƒ q" Wn  |  r‰ |  j ƒ  ru | j d d g ƒ | j |  ƒ q‰ | j t |  ƒ n  | r¤ t d j | ƒ t	 Sd S(   s  return ansi escape code corresponding to color and style

    :type color: str or None
    :param color:
      the color name (see `ANSI_COLORS` for available values)
      or the color number when 256 colors are available

    :type style: str or None
    :param style:
      style string (see `ANSI_COLORS` for available values). To get
      several style effects at the same time, use a coma as separator.

    :raise KeyError: if an unexistent color or style identifier is given

    :rtype: str
    :return: the built escape code
    t   38R   t   ;R   (
   R   t   _splitstript   appendt   ANSI_STYLESt   isdigitt   extendt   ANSI_COLORSt   ANSI_PREFIXt   joint   ANSI_END(   t   colort   stylet	   ansi_codet   style_attrst   effect(    (    s4   lib/python2.7/site-packages/pylint/reporters/text.pyt   _get_ansi_code:   s    c         C  sF   | d k r | d k r |  St | | ƒ } | rB d | |  t f S|  S(   sC  colorize message by wrapping it with ansi escape codes

    :type msg: str or unicode
    :param msg: the message string to colorize

    :type color: str or None
    :param color:
      the color identifier (see `ANSI_COLORS` for available values)

    :type style: str or None
    :param style:
      style string (see `ANSI_COLORS` for available values). To get
      several style effects at the same time, use a coma as separator.

    :raise KeyError: if an unexistent color or style identifier is given

    :rtype: str or unicode
    :return: the ansi escaped string
    s   %s%s%sN(   t   NoneR8   t
   ANSI_RESET(   t   msgR3   R4   t   escape_code(    (    s4   lib/python2.7/site-packages/pylint/reporters/text.pyt   colorize_ansi[   s    t   TextReporterc           B  sV   e  Z d  Z e Z d Z d Z d Z d	 d „ Z	 d „  Z
 d „  Z d „  Z d „  Z RS(
   s*   reports messages and layouts in plain textt   textt   txts+   {C}:{line:3d},{column:2d}: {msg} ({symbol})c         C  s)   t  j |  | ƒ t ƒ  |  _ d  |  _ d  S(   N(   R   t   __init__t   sett   _modulesR9   t	   _template(   t   selft   output(    (    s4   lib/python2.7/site-packages/pylint/reporters/text.pyRA      s    c         C  s(   t  j |  j j j p |  j ƒ |  _ d  S(   N(   t   sixt	   text_typet   lintert   configt   msg_templatet   line_formatRD   (   RE   t   modulet   filepath(    (    s4   lib/python2.7/site-packages/pylint/reporters/text.pyt   on_set_current_module†   s    c         C  s   |  j  | j |  j ƒ ƒ d S(   sJ   Convenience method to write a formated message with class default templateN(   t   writelnt   formatRD   (   RE   R;   (    (    s4   lib/python2.7/site-packages/pylint/reporters/text.pyt   write_message‰   s    c         C  sf   | j  |  j k rU | j  rE |  j d | j  ƒ |  j j | j  ƒ qU |  j d ƒ n  |  j | ƒ d S(   s;   manage message of different type and in the context of paths   ************* Module %ss   ************* N(   RM   RC   RP   t   addRR   (   RE   R;   (    (    s4   lib/python2.7/site-packages/pylint/reporters/text.pyt   handle_message   s    	c         C  s*   t  d |  j ƒ t ƒ  j | |  j ƒ d S(   s   launch layouts displayt   fileN(   t   printt   outR   RQ   (   RE   t   layout(    (    s4   lib/python2.7/site-packages/pylint/reporters/text.pyt   _display—   s    N(   t   __name__t
   __module__t   __doc__R   t   __implements__t   namet	   extensionRL   R9   RA   RO   RR   RT   RY   (    (    (    s4   lib/python2.7/site-packages/pylint/reporters/text.pyR>   y   s   			
t   ParseableTextReporterc           B  s&   e  Z d  Z d Z d Z d d „ Z RS(   s’   a reporter very similar to TextReporter, but display messages in a form
    recognized by most text editors :

    <filename>:<linenum>:<msg>
    t	   parseables0   {path}:{line}: [{msg_id}({symbol}), {obj}] {msg}c         C  s4   t  j d |  j |  j f t ƒ t j |  | ƒ d  S(   NsG   %s output format is deprecated. This is equivalent to --msg-template=%s(   t   warningst   warnR^   RL   t   DeprecationWarningR>   RA   (   RE   RF   (    (    s4   lib/python2.7/site-packages/pylint/reporters/text.pyRA   ¦   s    	N(   RZ   R[   R\   R^   RL   R9   RA   (    (    (    s4   lib/python2.7/site-packages/pylint/reporters/text.pyR`      s   t   VSTextReporterc           B  s   e  Z d  Z d Z d Z RS(   s   Visual studio text reportert   msvss/   {path}({line}): [{msg_id}({symbol}){obj}] {msg}(   RZ   R[   R\   R^   RL   (    (    (    s4   lib/python2.7/site-packages/pylint/reporters/text.pyRe   ­   s   t   ColorizedTextReporterc           B  sl   e  Z d  Z d Z i d d 6d d 6d d 6d d
 6d d 6d d 6d d 6Z d d d „ Z d „  Z d „  Z RS(   s.   Simple TextReporter that colorizes text outputt	   colorizedR   t   IR   t   CR#   s   bold, italict   RR!   t   WR   t   Es   bold, underlinet   FR   R   t   Sc         C  s†   t  j |  | ƒ | p" t t j ƒ |  _ d d g } t j j d ƒ | k r‚ t	 j
 d k r‚ d d  l } | j |  j ƒ |  _ q‚ n  d  S(   Ns   xterm-16colors   xterm-256colort   TERMt   win32iÿÿÿÿ(   R>   RA   t   dictRg   t   COLOR_MAPPINGt   color_mappingt   ost   environt   gett   syst   platformt   coloramat   AnsiToWin32RW   (   RE   RF   Rt   t
   ansi_termsRz   (    (    s4   lib/python2.7/site-packages/pylint/reporters/text.pyRA   Á   s    c         C  s,   y |  j  | d SWn t k
 r' d SXd S(   sg   Returns the tuple color, style associated with msg_id as defined
        in self.color_mapping
        i    N(   NN(   Rt   t   KeyErrorR9   (   RE   t   msg_id(    (    s4   lib/python2.7/site-packages/pylint/reporters/text.pyt   _get_decorationË   s    c           sÖ   ˆ j  |  j k rˆ |  j d ƒ \ ‰  ‰ ˆ j  rL t d ˆ j  ˆ  ˆ ƒ } n t d ˆ j  ˆ  ˆ ƒ } |  j | ƒ |  j j ˆ j  ƒ n  |  j ˆ j ƒ \ ‰  ‰ ˆ j ‡  ‡ ‡ f d †  d
 Dƒ   ‰ |  j ˆ ƒ d	 S(   s_   manage message of different types, and colorize output
        using ansi escape codes
        Ro   s   ************* Module %ss   ************* %sc           s.   i  |  ]$ } t  t ˆ | ƒ ˆ  ˆ ƒ | “ q S(    (   R=   t   getattr(   t   .0t   attr(   R3   R;   R4   (    s4   lib/python2.7/site-packages/pylint/reporters/text.pys
   <dictcomp>å   s   	R;   t   symbolt   categoryRj   N(   R;   Rƒ   R„   Rj   (	   RM   RC   R   R=   RP   RS   Rj   t   _replaceRR   (   RE   R;   t   modsep(    (   R3   R;   R4   s4   lib/python2.7/site-packages/pylint/reporters/text.pyRT   Ô   s    	N(   R   N(   NR   (   R#   s   bold, italic(   R!   N(   R   R   (   R   s   bold, underline(   R   R   (	   RZ   R[   R\   R^   R9   Rs   RA   R   RT   (    (    (    s4   lib/python2.7/site-packages/pylint/reporters/text.pyRg   ³   s   

		c         C  s8   |  j  t ƒ |  j  t ƒ |  j  t ƒ |  j  t ƒ d S(   s.   Register the reporter classes with the linter.N(   t   register_reporterR>   R`   Re   Rg   (   RI   (    (    s4   lib/python2.7/site-packages/pylint/reporters/text.pyt   registerê   s    (   R\   t
   __future__R    Ru   Rb   Rx   RG   t   pylint.interfacesR   t   pylint.reportersR   t   pylintR   t%   pylint.reporters.ureports.text_writerR   t   TITLE_UNDERLINESR0   R2   R:   R,   R/   R9   R8   R=   R>   R`   Re   Rg   Rˆ   (    (    (    s4   lib/python2.7/site-packages/pylint/reporters/text.pyt   <module>   sL   

!$7