ó
„¾^Yc           @   sA   d  Z  d d l Z d d l Z d e f d „  ƒ  YZ d „  Z d S(   s   
Provide the Reporter class.
iÿÿÿÿNt   Reporterc           B   s2   e  Z d  Z d „  Z d „  Z d „  Z d „  Z RS(   s:   
    Formats the results of pyflakes checks to users.
    c         C   s   | |  _  | |  _ d S(   s©  
        Construct a L{Reporter}.

        @param warningStream: A file-like object where warnings will be
            written to.  The stream's C{write} method must accept unicode.
            C{sys.stdout} is a good value.
        @param errorStream: A file-like object where error output will be
            written to.  The stream's C{write} method must accept unicode.
            C{sys.stderr} is a good value.
        N(   t   _stdoutt   _stderr(   t   selft   warningStreamt   errorStream(    (    s3   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/reporter.pyt   __init__   s    	c         C   s   |  j  j d | | f ƒ d S(   s  
        An unexpected error occurred trying to process C{filename}.

        @param filename: The path to a file that we could not process.
        @ptype filename: C{unicode}
        @param msg: A message explaining the problem.
        @ptype msg: C{unicode}
        s   %s: %s
N(   R   t   write(   R   t   filenamet   msg(    (    s3   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/reporter.pyt   unexpectedError   s    	c         C   sÔ   | j  ƒ  d } | d	 k	 r] | t | ƒ t | ƒ } |  j j d | | | d | f ƒ n |  j j d | | | f ƒ |  j j | ƒ |  j j d ƒ | d	 k	 rÐ |  j j t j d d | |  ƒ d ƒ n  d	 S(
   s0  
        There was a syntax error in C{filename}.

        @param filename: The path to the file with the syntax error.
        @ptype filename: C{unicode}
        @param msg: An explanation of the syntax error.
        @ptype msg: C{unicode}
        @param lineno: The line number where the syntax error occurred.
        @ptype lineno: C{int}
        @param offset: The column on which the syntax error occurred, or None.
        @ptype offset: C{int}
        @param text: The source code containing the syntax error.
        @ptype text: C{unicode}
        iÿÿÿÿs   %s:%d:%d: %s
i   s
   %s:%d: %s
s   
s   \St    s   ^
N(   t
   splitlinest   Nonet   lenR   R   t   ret   sub(   R   R   R	   t   linenot   offsett   textt   line(    (    s3   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/reporter.pyt   syntaxError'   s    c         C   s*   |  j  j t | ƒ ƒ |  j  j d ƒ d S(   sp   
        pyflakes found something wrong with the code.

        @param: A L{pyflakes.messages.Message}.
        s   
N(   R   R   t   str(   R   t   message(    (    s3   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/reporter.pyt   flakeC   s    (   t   __name__t
   __module__t   __doc__R   R
   R   R   (    (    (    s3   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/reporter.pyR    	   s
   			c           C   s   t  t j t j ƒ S(   sI   
    Make a reporter that can be used when no reporter is specified.
    (   R    t   syst   stdoutt   stderr(    (    (    s3   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/reporter.pyt   _makeDefaultReporterM   s    (   R   R   R   t   objectR    R   (    (    (    s3   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/reporter.pyt   <module>   s   D