HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib/python3/dist-packages/twisted/python/__pycache__/htmlizer.cpython-38.pyc
U


W[�
�@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.
    )rrr�utf-8cCs
||_dS)zJ
        @param writer: A file-like object, opened in bytes mode.
        N)�writer)�selfr	�r�9/usr/lib/python3/dist-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� Z
identifierr�keywordZ	parameterZvariable)sdefsclass�:)�hasattr�tokenizer�encoding�
isinstance�bytes�encode�currentLiner	�
currentCol�lastIdentifier�
parameters�NAMEr�	iskeyword�tok_name�get�lower�count)
r
�type�tokenZsCoordinatesZeCoordinates�lineZsrowZscolZerowZecolrrr�
printtoken!s:





zTokenPrinter.printtokenN)�__name__�
__module__�__qualname__�__doc__rrrrrr
r&rrrrrs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)r	rZaccumulateClassList�	__class__r,)r
r	r,rrrr
PszHTMLWriter.__init__NcCsht|t�r|�d�}t|�}|�d�}|dks8||jkrD|�|�n |�d|�d�d|d�dS)Nrs<span class="py-src-s">s</span>)rr�decoderrr,r	)r
r$r#rrr�writeWs


���zHTMLWriter.write)N)r'r(r)r*r,r
r/rrrrr+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,rrrrr0esr0c
Cst|�d�t||j�j�j}z2t|j�D]"}|\}}}}}	||||||	�q(Wntjk
rdYnX|�d�dS)Ns<pre>s</pre>
)r/rr&r�readliner�
TokenError)
Zinp�outr	Zprinterr$Z	tokenType�string�start�endr%rrr�filteros
r<c	CsBddl}t|jd|j�}t|jdd��}t||�W5QRXdS)Nr�bufferr�rb)�sys�getattr�stdout�open�argvr<)r?rA�frrr�main|srE�__main__)r*Ztwisted.python.compatrrrr�rZtwisted.python._oldstylerrr+r0r<rEr'rrrr�<module>s6