B
    &e                 @   sz   d Z ddlmZ ddlmZ ddlmZ ddlmZ dddgZ	G d	d deZ
G d
d deZdZdZG dd deZdS )z
    pygments.formatters.other
    ~~~~~~~~~~~~~~~~~~~~~~~~~

    Other formatters: NullFormatter, RawTokenFormatter.

    :copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
    )	Formatter)get_choice_opt)Token)colorizeNullFormatterRawTokenFormatterTestcaseFormatterc               @   s*   e Zd ZdZdZddgZdgZdd ZdS )	r   z;
    Output the text unchanged without any formatting.
    z	Text onlytextnullz*.txtc             C   s<   | j }x0|D ](\}}|r*||| q|| qW d S )N)encodingwriteencode)selftokensourceoutfileencttypevalue r   T/home/dcms/DCMS/lib/python3.7/site-packages/pip/_vendor/pygments/formatters/other.pyformat   s
    zNullFormatter.formatN)__name__
__module____qualname____doc__namealiases	filenamesr   r   r   r   r   r      s
   c               @   s6   e Zd ZdZdZddgZdgZdZdd Zd	d
 Z	dS )r   a}  
    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

    z
Raw tokensrawtokensz*.rawFc             K   s   t j| f| d| _t|dddddgd| _|dd | _| jdkrJd	| _| jd k	ryt| jd W n" tk
r   t	d
| j Y nX d S )Nasciicompress nonegzbz2error_colorTredzInvalid color %r specified)
r   __init__r   r   r!   getr&   r   KeyError
ValueError)r   optionsr   r   r   r(   >   s    

zRawTokenFormatter.__init__c       
         s  y d W n tk
r*   tdY nX | jdkr\dd l}|dddj }j}nF| jdkrdd l}|d  fd	d
} fdd}nj }j}| j	rxd|D ]8\}}d||f }	|t
jkr|t| j	|	 q||	 qW n"x |D ]\}}|d||f  qW |  d S )N    z3The raw tokens formatter needs a binary output filer$   r   r"   wb	   r%   c                s     |  d S )N)r   r!   )r	   )
compressorr   r   r   r   `   s    z'RawTokenFormatter.format.<locals>.writec                  s         d S )N)r   flushr   )r0   r   r   r   r1   c   s    z'RawTokenFormatter.format.<locals>.flushs   %r	%r
)r   	TypeErrorr!   gzipGzipFilecloser%   BZ2Compressorr1   r&   r   Errorr   )
r   r   r   r3   r   r1   r%   r   r   liner   )r0   r   r   r   P   s2    



zRawTokenFormatter.formatN)
r   r   r   r   r   r   r   Zunicodeoutputr(   r   r   r   r   r   r   $   s   zG    def testNeedsName(lexer):
        fragment = %r
        tokens = [
zD        ]
        assert list(lexer.get_tokens(fragment)) == tokens
c               @   s*   e Zd ZdZdZdgZdd Zdd ZdS )	r   zU
    Format tokens as appropriate for a new testcase.

    .. versionadded:: 2.0
    ZTestcaseZtestcasec             K   s.   t j| f| | jd k	r*| jdkr*tdd S )Nzutf-8z*Only None and utf-8 are allowed encodings.)r   r(   r   r+   )r   r,   r   r   r   r(      s    zTestcaseFormatter.__init__c             C   s   d}g }g }x.|D ]&\}}| | | d|||f  qW td|f }d|}	t}
| jd krx|||	 |
  n0||d ||	d ||
d |  d S )Nz            z%s(%s, %r),
r"   zutf-8)appendTESTCASE_BEFOREjoinTESTCASE_AFTERr   r   r   r1   )r   r   r   indentationZrawbufZoutbufr   r   beforeZduringafterr   r   r   r      s    


zTestcaseFormatter.formatN)r   r   r   r   r   r   r(   r   r   r   r   r   r      s
   N)r   Zpip._vendor.pygments.formatterr   pip._vendor.pygments.utilr   pip._vendor.pygments.tokenr   Zpip._vendor.pygments.consoler   __all__r   r   r:   r<   r   r   r   r   r   <module>	   s   
W