ó
²h[Tc           @   s­   d  Z  d d l m Z d d l m Z m Z d d l m Z d d l m	 Z	 d d d g Z
 d e f d	     YZ d e f d
     YZ d Z d Z d e f d     YZ d S(   sź   
    pygments.formatters.other
    ~~~~~~~~~~~~~~~~~~~~~~~~~

    Other formatters: NullFormatter, RawTokenFormatter.

    :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
i’’’’(   t	   Formatter(   t   OptionErrort   get_choice_opt(   t   Token(   t   colorizet   NullFormattert   RawTokenFormattert   TestcaseFormatterc           B   s2   e  Z d  Z d Z d d g Z d g Z d   Z RS(   s;   
    Output the text unchanged without any formatting.
    s	   Text onlyt   textt   nulls   *.txtc         C   sP   |  j  } x@ | D]8 \ } } | r; | j | j |   q | j |  q Wd  S(   N(   t   encodingt   writet   encode(   t   selft   tokensourcet   outfilet   enct   ttypet   value(    (    s=   /usr/lib/python2.7/dist-packages/pygments/formatters/other.pyt   format   s
    	(   t   __name__t
   __module__t   __doc__t   namet   aliasest	   filenamesR   (    (    (    s=   /usr/lib/python2.7/dist-packages/pygments/formatters/other.pyR      s
   	c           B   sA   e  Z d  Z d Z d d g Z d g Z e Z d   Z d   Z	 RS(   s}  
    Format tokens as a raw representation for storing token streams.

    The format is ``tokentype<TAB>repr(tokenstring)\n``. The output can later
    be converted to a token stream with the `RawTokenLexer`, described in the
    :doc:`lexer list <lexers>`.

    Only two options are accepted:

    `compress`
        If set to ``'gz'`` or ``'bz2'``, compress the output with the given
        compression algorithm after encoding (default: ``''``).
    `error_color`
        If set to a color name, highlight error tokens using that color.  If
        set but with no value, defaults to ``'red'``.

        .. versionadded:: 0.11

    s
   Raw tokenst   rawt   tokenss   *.rawc         K   s¾   t  j |  |  d |  _ t | d d d d d g d  |  _ | j d d   |  _ |  j t k rm d |  _ n  |  j d  k	 rŗ y t	 |  j d  Wqŗ t
 k
 r¶ t d	 |  j   qŗ Xn  d  S(
   Nt   asciit   compresst    t   nonet   gzt   bz2t   error_colort   reds   Invalid color %r specified(   R    t   __init__R
   R   R   t   gett   NoneR"   t   TrueR   t   KeyErrort
   ValueError(   R   t   options(    (    s=   /usr/lib/python2.7/dist-packages/pygments/formatters/other.pyR$   ?   s    		c   
         s  y  j  d  Wn t k
 r0 t d   n X|  j d k r d d  l } | j d d d     f d   }  j } ni |  j d k rŠ d d  l } | j d       f d	   }    f d
   } n  f d   }  j } |  j rMx | D]N \ } } d | | f }	 | t	 j
 k r<| t |  j |	   qų | |	  qų Wn+ x( | D]  \ } } | d | | f  qTW|   d  S(   NR   s3   The raw tokens formatter needs a binary output fileR    i’’’’t   wbi	   c            s     j  |  j    d  S(   N(   R   R   (   R   (   R   (    s=   /usr/lib/python2.7/dist-packages/pygments/formatters/other.pyR   Z   s    R!   c            s     j    j |  j     d  S(   N(   R   R   R   (   R   (   t
   compressorR   (    s=   /usr/lib/python2.7/dist-packages/pygments/formatters/other.pyR   `   s    c              s!    j    j     j   d  S(   N(   R   t   flush(    (   R,   R   (    s=   /usr/lib/python2.7/dist-packages/pygments/formatters/other.pyR-   b   s    c            s     j  |  j    d  S(   N(   R   R   (   R   (   R   (    s=   /usr/lib/python2.7/dist-packages/pygments/formatters/other.pyR   f   s    s   %s	%r
(   R   t	   TypeErrorR   t   gzipt   GzipFileR-   R!   t   BZ2CompressorR"   R   t   ErrorR   (
   R   R   R   R/   R   R-   R!   R   R   t   line(    (   R,   R   s=   /usr/lib/python2.7/dist-packages/pygments/formatters/other.pyR   Q   s2    		(
   R   R   R   R   R   R   t   Falset   unicodeoutputR$   R   (    (    (    s=   /usr/lib/python2.7/dist-packages/pygments/formatters/other.pyR   %   s   		uF       def testNeedsName(self):
        fragment = %r
        tokens = [
uR           ]
        self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))
c           B   s/   e  Z d  Z d Z d g Z d   Z d   Z RS(   sU   
    Format tokens as appropriate for a new testcase.

    .. versionadded:: 2.0
    t   Testcaset   testcasec         K   sA   t  j |  |  |  j d  k	 r= |  j d k r= t d   n  d  S(   Ns   utf-8s*   Only None and utf-8 are allowed encodings.(   R    R$   R
   R&   R)   (   R   R*   (    (    s=   /usr/lib/python2.7/dist-packages/pygments/formatters/other.pyR$      s    c         C   sņ   d } g  } g  } x; | D]3 \ } } | j  |  | j  d | | | f  q Wt d j |  f } d j |  }	 t }
 |  j d  k r¢ | j | |	 |
  nB | j | j d   | j |	 j d   | j |
 j d   | j   d  S(   Nt    i   s   %s(%s, %r),
u    s   utf-8s               (	   t   appendt   TESTCASE_BEFOREt   joint   TESTCASE_AFTERR
   R&   R   R   R-   (   R   R   R   t   indentationt   rawbuft   outbufR   R   t   beforet   duringt   after(    (    s=   /usr/lib/python2.7/dist-packages/pygments/formatters/other.pyR      s    (   R   R   R   R   R   R$   R   (    (    (    s=   /usr/lib/python2.7/dist-packages/pygments/formatters/other.pyR      s
   		N(   R   t   pygments.formatterR    t   pygments.utilR   R   t   pygments.tokenR   t   pygments.consoleR   t   __all__R   R   R:   R<   R   (    (    (    s=   /usr/lib/python2.7/dist-packages/pygments/formatters/other.pyt   <module>
   s   U