a
    lc                     @   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-2022 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   U/var/www/html/django/DPS/env/lib/python3.9/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rzt| jd W n  ty   t	d| j Y n0 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Y n0 | jdkrZd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	r|D ]8\}}d||f }	|t
ju r|t| j	|	 q||	 qn|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   c   s    z'RawTokenFormatter.format.<locals>.flushs   %r	%r
)r   	TypeErrorr"   gzipGzipFilecloser&   BZ2Compressorr3   r'   r   Errorr   )
r   r   r   r5   r   r3   r&   r   r   liner   r2   r   r   P   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|||f  qtd|f }d|}	t}
| jd u rt|||	 |
  n0||d ||	d ||
d |  d S )Nz            z%s(%s, %r),
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=   r?   r   r   r   r   r   <module>   s   
S