a
    ñ»j�  ã                   @   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-present 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   ú?E:\soccer\ml_env\Lib\site-packages\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 rJd| _| jd urŠzt| jdƒ W n$ tyˆ   t	d| j›d	�ƒ‚Y n0 d S )
NÚasciiÚcompress)Ú ÚnoneÚgzÚbz2r#   Úerror_colorTÚredzInvalid color z
 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ƒ‚Y n0 | jdkrZdd l}| dddˆ¡‰ˆj }ˆj}nF| jdkr”dd l}| d¡‰ ‡ ‡fd	d
„}‡ ‡fdd„}nˆj }ˆj}| j	rî|D ]@\}}d||f }	|t
ju râ|t| j	|	 ¡ ƒ ¡ ƒ qª||	ƒ qªn|D ]\}}|d||f ƒ qò|ƒ  d S )Nó    z3The raw tokens formatter needs a binary output filer%   r   r#   Úwbé	   r&   c                    s   ˆ  ˆ  | ¡¡ d S r   )r   r"   )r	   ©Z
compressorr   r   r   r   _   s    z'RawTokenFormatter.format.<locals>.writec                      s   ˆ  ˆ  ¡ ¡ ˆ ¡  d S r   )r   Úflushr   r2   r   r   r3   b   s    z'RawTokenFormatter.format.<locals>.flushs   %r	%r
)r   Ú	TypeErrorr"   ÚgzipÚGzipFileÚcloser&   ÚBZ2Compressorr3   r'   r   ÚErrorr   Údecoder   )
r   r   r   r5   r   r3   r&   r   r   Úliner   r2   r   r   O   s2    



zRawTokenFormatter.formatN)
r   r   r   r   r   r   r   Z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
    ZTestcaseZtestcasec                 K   s2   t j| fi |¤Ž | jd ur.| jdkr.tdƒ‚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|› d|›d�¡ qtd |¡f }d |¡}	t}
| jd u r|| ||	 |
 ¡ n0| | d¡¡ | |	 d¡¡ | |
 d¡¡ | ¡  d S )Nz            ú(z, z),
r#   r<   )ÚappendÚTESTCASE_BEFOREÚjoinÚTESTCASE_AFTERr   r   r   r3   )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
   r   N)r   Zpygments.formatterr   Zpygments.utilr   Zpygments.tokenr   Zpygments.consoler   Ú__all__r   r   r?   rA   r   r   r   r   r   Ú<module>   s   
R