Your IP : 216.73.216.213


Current Path : /opt/alt/python37/lib64/python3.7/site-packages/twisted/python/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/site-packages/twisted/python/__pycache__/htmlizer.cpython-37.pyc

B

:��]�
�@s�dZddlmZmZddlZddlZddlmZddlm	Z	e	Gdd�d��Z
e	Gd	d
�d
��ZGdd�de�Zefd
d�Z
dd�Zedkr�e�dS)z"
HTML rendering of Python source.
�)�	_tokenize�escapeN�)�reflect)�	_oldStylec@s4eZdZdZd\ZZdZZdZdd�Z	dd�Z
d	S)
�TokenPrinterzU
    Format a stream of tokens and intermediate whitespace, for pretty-printing.
    )rrrzutf-8cCs
||_dS)zJ
        @param writer: A file-like object, opened in bytes mode.
        N)�writer)�selfr�r
�J/opt/alt/python37/lib64/python3.7/site-packages/twisted/python/htmlizer.py�__init__szTokenPrinter.__init__c
Cs(ttd�r|tjkr||_dSt|t�s4|�|j�}|\}}|\}}	|j|krp|�d||j�|d|_|_	|�d||j	�|j
r�d}d|_n<|tjkr�t
�|�r�d}q�|jr�d}q�d	}ntj�|���}|�||�|	|_	|j|�d�7_|j|k�r
d|_	|d
k|_
|dk�r$d|_dS)N�ENCODING�
r� �
identifierr�keywordZ	parameter�variable)sdefsclass�:)�hasattr�tokenizer
�encoding�
isinstance�bytes�encode�currentLiner�
currentCol�lastIdentifier�
parameters�NAMEr�	iskeyword�tok_name�get�lower�count)
r	�type�tokenZsCoordinatesZeCoordinates�lineZsrowZscolZerowZecolr
r
r�
printtoken!s:





zTokenPrinter.printtokenN)�__name__�
__module__�__qualname__�__doc__rrrrrrr'r
r
r
rrsrc@s&eZdZdZgZdd�Zddd�ZdS)�
HTMLWriterzm
    Write the stream of tokens and whitespace from L{TokenPrinter}, formating
    tokens as HTML spans.
    cCs$||_g}t�|jd|�||_dS)N�noSpan)rrZaccumulateClassList�	__class__r-)r	rr-r
r
rrPszHTMLWriter.__init__NcCsht|t�r|�d�}t|�}|�d�}|dks8||jkrD|�|�n |�d|�d�d|d�dS)Nzutf-8s<span class="py-src-s">s</span>)rr�decoderrr-r)r	r%r$r
r
r�writeWs


zHTMLWriter.write)N)r(r)r*r+r-rr0r
r
r
rr,Gsr,c@s eZdZdZddddddgZdS)	�SmallerHTMLWriterzi
    HTMLWriter that doesn't generate spans for some junk.

    Results in much smaller HTML output.
    Z	endmarker�indent�dedent�op�newline�nlN)r(r)r*r+r-r
r
r
rr1esr1c
Csx|�d�t||j�j�j}y6x0t|j�D]"}|\}}}}}	||||||	�q*WWntjk
rhYnX|�d�dS)Ns<pre>s</pre>
)r0rr'r�readliner�
TokenError)
Zinp�outr�printerr%Z	tokenType�string�start�endr&r
r
r�filteros
r>c	CsBddl}t|jd|j�}t|jdd��}t||�WdQRXdS)Nr�bufferr�rb)�sys�getattr�stdout�open�argvr>)rArC�fr
r
r�main|srG�__main__)r+Ztwisted.python.compatrrrr�rZtwisted.python._oldstylerrr,r1r>rGr(r
r
r
r�<module>s7