Your IP : 216.73.216.213


Current Path : /opt/alt/python37/lib/python3.7/site-packages/pygments/formatters/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/pygments/formatters/__pycache__/other.cpython-37.pyc

B

ͽ�\*�@s~dZddlmZddlmZmZddlmZddlm	Z	dddgZ
Gd	d�de�ZGd
d�de�ZdZ
dZGd
d�de�ZdS)z�
    pygments.formatters.other
    ~~~~~~~~~~~~~~~~~~~~~~~~~

    Other formatters: NullFormatter, RawTokenFormatter.

    :copyright: Copyright 2006-2019 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
�)�	Formatter)�OptionError�get_choice_opt)�Token)�colorize�
NullFormatter�RawTokenFormatter�TestcaseFormatterc@s*eZdZdZdZddgZdgZdd�ZdS)	rz;
    Output the text unchanged without any formatting.
    z	Text only�textZnullz*.txtcCs<|j}x0|D](\}}|r*|�|�|��q|�|�qWdS)N)�encoding�write�encode)�self�tokensource�outfile�enc�ttype�value�r�J/opt/alt/python37/lib/python3.7/site-packages/pygments/formatters/other.py�formats
zNullFormatter.formatN)�__name__�
__module__�__qualname__�__doc__�name�aliases�	filenamesrrrrrrs
c@s6eZdZdZdZddgZdgZdZdd�Zd	d
�Z	dS)ra}
    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*.rawFcKs�tj|f|�d|_t|dddddgd�|_|�dd�|_|jdkrJd	|_|jdk	r�yt|jd�Wn"tk
r�t	d
|j��YnXdS)N�ascii�compress�Znone�gz�bz2�error_colorTZredzInvalid color %r specified)
r�__init__rrr!�getr%r�KeyError�
ValueError)r�optionsrrrr&?s

zRawTokenFormatter.__init__c
s$y��d�Wntk
r*td��YnX|jdkrbddl}|�ddd����fdd	�}�j}nL|jd
kr�ddl}|�d����fdd	�}��fdd
�}n�fdd	�}�j}|jr�xd|D]8\}}d||f}	|t	j
kr�|t|j|	��q�||	�q�Wn"x |D]\}}|d||f�q�W|�dS)N�z3The raw tokens formatter needs a binary output filer#rr"�wb�	cs��|���dS)N)rr
)r
)rrrrZsz'RawTokenFormatter.format.<locals>.writer$cs����|����dS)N)rr!r
)r
)�
compressorrrrr`scs���������dS)N)r�flushr)r.rrrr/bsz'RawTokenFormatter.format.<locals>.flushcs��|���dS)N)rr
)r
)rrrrfsz%s	%r
)r�	TypeErrorr!�gzipZGzipFiler/r$�
BZ2Compressorr%r�Errorr)
rrrr1rr/r$rr�liner)r.rrrQs2



zRawTokenFormatter.formatN)
rrrrrrrZ
unicodeoutputr&rrrrrr%szF    def testNeedsName(self):
        fragment = %r
        tokens = [
zR        ]
        self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))
c@s*eZdZdZdZdgZdd�Zdd�ZdS)	r	zU
    Format tokens as appropriate for a new testcase.

    .. versionadded:: 2.0
    ZTestcaseZtestcasecKs.tj|f|�|jdk	r*|jdkr*td��dS)Nzutf-8z*Only None and utf-8 are allowed encodings.)rr&rr))rr*rrrr&�szTestcaseFormatter.__init__cCs�d}g}g}x.|D]&\}}|�|�|�d|||f�qWtd�|�f}d�|�}	t}
|jdkrx|�||	|
�n0|�|�d��|�|	�d��|�|
�d��|��dS)Nz            z%s(%s, %r),
r"zutf-8)�append�TESTCASE_BEFORE�join�TESTCASE_AFTERrrr
r/)rrrZindentationZrawbufZoutbufrr�beforeZduring�afterrrrr�s


zTestcaseFormatter.formatN)rrrrrrr&rrrrrr	�s
N)rZpygments.formatterrZ
pygments.utilrrZpygments.tokenrZpygments.consoler�__all__rrr6r8r	rrrr�<module>
s
U