HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib64/python3.10/site-packages/mako/__pycache__/pygen.cpython-310.pyc
o

%we�(�@s2dZddlZddlmZGdd�d�Zdd�ZdS)z<utilities for generating and formatting literal Python code.�N)�
exceptionsc@sxeZdZdd�Zdd�Zdd�Zdd�Zdd
d�Zdd
�Zdd�Z	dd�Z
dd�Zddd�Zdd�Z
dd�Zdd�Zd	S)�
PythonPrintercCs�d|_g|_d|_||_d|_g|_d|_|��i|_t	�
d�|_t	�
d�|_t	�
d�|_
t	�
d�|_t	�
d	�|_t	�
d
�|_dS)Nrz    �Fz^\s*#z^\s*$z:[ \t]*(?:#.*)?$z ^\s*(if|try|elif|while|for|with)z(^\s*(def|class|else|elif|except|finally)z"^\s*(else|elif|except|finally).*\:)�indent�
indent_detail�indentstring�stream�lineno�line_buffer�in_indent_lines�_reset_multi_line_flags�
source_map�re�compile�_re_space_comment�	_re_space�
_re_indent�_re_compound�_re_indent_keyword�_re_unindentor)�selfr�r�C/home/arjun/projects/env/lib/python3.10/site-packages/mako/pygen.py�__init__s"�zPythonPrinter.__init__cCs|j|7_dS�N)r	�r�numrrr�_update_lineno7�zPythonPrinter._update_linenocCs |j|jvr||j|j<dSdSr)r	r
)rr	rrr�start_source:s�zPythonPrinter.start_sourcecCs|j�d|�|�|�dS)N�
)r�writerrrrr�write_blanks>szPythonPrinter.write_blanksNcCsPd|_tt�d|��D]\}}|j�|�|dur |�||�|�d�qdS)z�print a line or lines of python which already contain indentation.

        The indentation of the total block of lines will be adjusted to that of
        the current indent level.F�\r?\nNr)r�	enumerater�splitr
�appendrr)r�block�starting_lineno�i�lrrr�write_indented_blockBs�z"PythonPrinter.write_indented_blockcGs|D]}|�|�qdS)z"print a series of lines of python.N)�	writeline)r�lines�linerrr�
writelinesNs�zPythonPrinter.writelinescCsV|js
|��d|_|dus|j�|�s|j�|�rd}nd}|o*t|�o*|ddk}|sQ|r4|�|�rQ|jdkrQ|jd8_t|j�dkrLt	�
d��|j��|durWdS|j�
|�|�d�|�t|�d���|j�|�r�|j�|�}|r�|�d�}|jd7_|j�|�dSd}|j�|�}|r�|jd7_|j�|�dSdSdS)	z�print a line of python, indenting it according to the current
        indent level.

        this also adjusts the indentation counter according to the
        content of the line.

        TNFr�#rzToo many whitespace closuresr )r�_flush_adjusted_linesr�matchr�len�_is_unindentorrrr�
MakoException�poprr!�_indent_linerr%r�searchr�groupr&r)rr.�hastext�
is_commentr2�indentor�m2rrrr,SsN	
�
����



�zPythonPrinter.writelinecCs|��dS)z1close this printer, flushing any remaining lines.N)r1�rrrr�close�szPythonPrinter.closecCs<t|j�dkr	dS|jd}|durdS|j�|�}t|�S)zqreturn true if the given line is an 'unindentor',
        relative to the last 'indent' event received.

        rF���N)r3rrr2�bool)rr.r<r2rrrr4�s
zPythonPrinter._is_unindentor�cCs2|dkr|j|j|St�d||j|j|�S)z�indent the given line according to the current indent level.

        stripspace is a string of space that will be truncated from the
        start of the line before indenting.rB�^%s)rrr�sub)rr.�
stripspacerrrr7�s
�zPythonPrinter._indent_linecCsd\|_|_dS)z^reset the flags which would indicate we are in a backslashed
        or triple-quoted section.)FFN)�backslashed�triplequotedr>rrrr�sz%PythonPrinter._reset_multi_line_flagscCsP|jp|j}tt�d|��|_tt�d|��}|dks!|ddkr&|j|_|S)zcreturn true if the given line is part of a multi-line block,
        via backslash or triple-quote.�\\$�
\"\"\"|\'\'\'r�r)rFrGrArr8r3�findall)rr.�
current_state�triplesrrr�_in_multi_line�s

zPythonPrinter._in_multi_linecCs�d}|��|jD]3}|�|�r|j�|d�q	|��}|dur0t�d|�r0t�d|��	d�}|j�|�
||�d�q	g|_|��dS)Nr �^[ \t]*[^# \t]�	^([ \t]*)r)rr
rNrr!�
expandtabsrr8r2r9r7)rrE�entryrrrr1�s

z#PythonPrinter._flush_adjusted_linesr�rB)�__name__�
__module__�__qualname__rrrr"r+r/r,r?r4r7rrNr1rrrrrs(
G
(
rcs�ddg�d\�����fdd�}ddd�}g}d}t�d	|�D]+}||�r+|�|�q|��}|durBt�d
|�rBt�d|��d�}|�|||��qd
�|�S)z<remove the left-whitespace margin of a block of Python code.F)rrcs���p��}t�d|�rd��<nd��<dd�}|rd��r?|d��|�\}}|r3d��<n/|d��|�\}}n#|d|�\}}|rJ|S|d	|�\}}|r[|�d
���<q|d|�\}}|s|S)NrHTFcSs2t�||�}|r||t|�d��d�fSd|fS)Nr)rr2r3r9)�reg�t�mrrrr2sz7adjust_whitespace.<locals>.in_multi_line.<locals>.matchz%sz.*?(?=%s|$)r0rIrz.*?(?=\"\"\"|\'\'\'|#|$))rr8r9)r.�start_stater2rY�rF�staterGrr�
in_multi_lines*

�z(adjust_whitespace.<locals>.in_multi_linerBcSst�d|d|�S)NrCrB)rrD)r.rErrrr7'rz'adjust_whitespace.<locals>._indent_lineNr#rOrPrr rS)rr%r&rQr8r2r9�join)�textr]r7r-rEr.rr[r�adjust_whitespace�s
$
r`)�__doc__r�makorrr`rrrr�<module>sp