File: //home/arjun/projects/env/lib/python3.10/site-packages/mako/ext/__pycache__/extract.cpython-310.pyc
o
%we3 � @ sJ d dl mZ d dl mZ d dlZd dlmZ d dlmZ G dd� d�ZdS )� )�BytesIO)�StringION)�lexer)� parsetreec @ s, e Zd ZdZdd� Zdd� Zedd� �ZdS ) �MessageExtractorTc c s6 � t j|�� | jd d��� }| �|�� �E d H d S )N�encoding)�input_encoding)r �Lexer�read�config�parse�
extract_nodes�get_children)�self�fileobj�
template_node� r �I/home/arjun/projects/env/lib/python3.10/site-packages/mako/ext/extract.py�process_file s ���zMessageExtractor.process_filec c sN � g }d}| j d pd}ttd t�d| j d ���}|D �]}d }|r/t|tj�r/|j� � s/qt|tj
�r^|j� � }|rG|�| �
|j|�� q|D ]} |�| �r\d}|�| �
|j|�� qIqt|tj�rl|jj}
|j}n]t|tj�rz|jj}
|j}nOt|tj�r�|jj}
|j}nAt|tj�r�|jj}
n6t|tj�r�|j}
|j}n)t|tj�r�|jr�d}q|j}
nt|tj�r�d}|jj}
nt|tj�r�|jj}
nq|r�|d d |jd k r�g }d
d� |D �}t|
t�r�| jr�|
� |d�}
d}| jr�t!d
|
�}
nt"d|
�}
| �#|
|jd |�D ]}
|
V d}�q |�rg }d}|�r$| �$|�E d H qd S )NFr �asciiz\s+zcomment-tagsT���r � c S s g | ]}|d �qS )r r )�.0�commentr r r �
<listcomp>[ s �z2MessageExtractor.extract_nodes.<locals>.<listcomp>�backslashreplace�
�
)%r �list�filter�re�split�
isinstancer �Text�content�strip�Comment�text�extend�_split_comment�lineno�
startswith�DefTag�
function_decl�code�nodes�BlockTag� body_decl�CallTag�PageTag�CallNamespaceTag�
expression�ControlLine�isend�Code�
Expression�str� use_bytes�encoder r �process_pythonr
)r r/ �translator_comments�in_translator_commentsr �comment_tags�node�child_nodes�value�comment_tagr. �translator_strings�used_translator_comments�messager r r r
s� ��
�
��
�
��
�����zMessageExtractor.extract_nodesc s � fdd�t |�� �D �S )zzReturn the multiline comment at lineno split into a list of
comment line numbers and the accompanying comment linec s g | ]
\}}� | |f�qS r r )r �index�line�r* r r r ~ s
��z3MessageExtractor._split_comment.<locals>.<listcomp>)� enumerate�
splitlines)r* r r rJ r r) z s
�zMessageExtractor._split_commentN)�__name__�
__module__�__qualname__r; r r
�staticmethodr) r r r r r s br )�ior r r �makor r r r r r r �<module> s