o
    xi*                     @   s|   d Z ddlmZ ddlmZ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-2017 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
    )	Formatter)OptionError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/ubuntu/.local/lib/python3.10/site-packages/wandb/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fdd	}j}n&| jd
krKdd l}|d  fdd	} fdd}n	fdd	}j}| jrw|D ]\}}d||f }	|t	j
u rq|t| j|	 qY||	 qYn|D ]\}}|d||f  qy|  d S )N    z3The raw tokens formatter needs a binary output filer&   r   r$   wb	   c                         |   d S r   r   r   r
   r   r   r   r   Z      z'RawTokenFormatter.format.<locals>.writer'   c                    s     |   d S r   )r   r#   r   r5   
compressorr   r   r   r   `   s   c                      s         d S r   )r   flushr   r8   r   r   r:   b   s   z'RawTokenFormatter.format.<locals>.flushc                    r3   r   r4   r5   r6   r   r   r   f   r7   z%s	%r
)r   	TypeErrorr#   gzipGzipFiler:   r'   BZ2Compressorr(   r   Errorr   )
r   r   r   r<   r   r:   r'   r   r   liner   r8   r   r   Q   s6   





zRawTokenFormatter.formatN)
r   r   r   r   r   r   r   unicodeoutputr*   r   r   r   r   r   r   %   s    r   zF    def testNeedsName(self):
        fragment = %r
        tokens = [
zR        ]
        self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))
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$   rD   )appendTESTCASE_BEFOREjoinTESTCASE_AFTERr   r   r   r:   )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   r   pygments.tokenr   pygments.consoler   __all__r   r   rF   rH   r	   r   r   r   r   <module>   s   
Q