o
    !§ÑhÑ  ã                   @   sx   d Z ddlmZ ddlmZ ddlmZ ddlmZ g d¢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-2021 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   s8   | j }|D ]\}}|r| | |¡¡ q| |¡ qd S ©N)ÚencodingÚwriteÚencode)ÚselfÚtokensourceÚoutfileÚencÚttypeÚvalue© r   úG/usr/lib/python3/dist-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    r   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i |¤Ž d| _t|dg d¢dƒ| _| dd ¡| _| jdu r%d| _| jd urBz	t| jdƒ W d S  tyA   t	d| j ƒ‚w d S )	NÚasciiÚcompress)Ú ÚnoneÚgzÚbz2r#   Ú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
  zˆ  d¡ W n ty   tdƒ‚w | jdkr+dd l}| dddˆ¡‰ˆj }ˆj}n#| jdkrHdd l}| d¡‰ ‡ ‡fd	d
„}‡ ‡fdd„}nˆj }ˆj}| j	rq|D ]\}}d||f }	|t
ju rk|t| j	|	ƒƒ qS||	ƒ qSn|D ]\}}|d||f ƒ qs|ƒ  d S )Nó    z3The raw tokens formatter needs a binary output filer%   r   r#   Úwbé	   r&   c                    s   ˆ  ˆ  | ¡¡ d S r   )r   r"   )r	   ©Ú
compressorr   r   r   r   `   s   z'RawTokenFormatter.format.<locals>.writec                      s   ˆ  ˆ  ¡ ¡ ˆ ¡  d S r   )r   Úflushr   r2   r   r   r4   c   s   z'RawTokenFormatter.format.<locals>.flushs   %r	%r
)r   Ú	TypeErrorr"   ÚgzipÚGzipFileÚcloser&   ÚBZ2Compressorr4   r'   r   ÚErrorr   )
r   r   r   r6   r   r4   r&   r   r   Úliner   r2   r   r   P   s6   ÿ




û
zRawTokenFormatter.formatN)
r   r   r   r   r   r   r   Úunicodeoutputr)   r   r   r   r   r   r   $   s    r   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
    ÚTestcaseÚtestcasec                 K   s6   t j| fi |¤Ž | jd ur| jdkrtdƒ‚d S d S )Núutf-8z*Only None and utf-8 are allowed encodings.)r   r)   r   r,   r-   r   r   r   r)   ‹   s   ÿzTestcaseFormatter.__init__c                 C   s°   d}g }g }|D ]\}}|  |¡ |  d|||f ¡ qtd |¡f }d |¡}	t}
| jd u r:| ||	 |
 ¡ n| | d¡¡ | |	 d¡¡ | |
 d¡¡ | ¡  d S )Nz            z%s(%s, %r),
r#   r?   )ÚappendÚTESTCASE_BEFOREÚjoinÚTESTCASE_AFTERr   r   r   r4   )r   r   r   ÚindentationÚrawbufÚoutbufr   r   ÚbeforeÚduringÚafterr   r   r   r   �   s   


zTestcaseFormatter.formatN)r   r   r   r   r   r   r)   r   r   r   r   r   r   ‚   s    r   N)r   Úpip._vendor.pygments.formatterr   Úpip._vendor.pygments.utilr   Úpip._vendor.pygments.tokenr   Úpip._vendor.pygments.consoler   Ú__all__r   r   rA   rC   r   r   r   r   r   Ú<module>   s    
S