o
    Ñ­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   úV/var/www/html/CropPilot/venv/lib/python3.10/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 r%d| _| jd urDz	t| jdƒ W d S  tyC   t	d| j›d	�ƒ‚w 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ƒ‚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   b   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   O   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|› d|›d�¡ qtd |¡f }d |¡}	t}
| jd u r>| ||	 |
 ¡ n| | d¡¡ | |	 d¡¡ | |
 d¡¡ | ¡  d S )Nz            ú(z, z),
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   Úpygments.formatterr   Úpygments.utilr   Úpygments.tokenr   Úpygments.consoler   Ú__all__r   r   rB   rD   r   r   r   r   r   Ú<module>   s    
R