o
    Thz                     @   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-2025 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   Z/home/air/segue/gemini/back/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