o
    h3                     @   sJ   d dl mZ d dl mZ d dlZd dlmZ d dlmZ G dd dZdS )    )BytesIO)StringION)lexer)	parsetreec                   @   s,   e Zd ZdZdd Zdd Zedd ZdS )	MessageExtractorTc                 c   s6    t j| | jd d }| | E d H  d S )Nencoding)input_encoding)r   Lexerreadconfigparseextract_nodesget_children)selffileobjtemplate_node r   d/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/mako/ext/extract.pyprocess_file   s   zMessageExtractor.process_filec                 c   sN   g }d}| j d pd}ttd td| j d }|D ]}d }|r/t|tjr/|j	 s/qt|tj
r^|j	 }|rG|| |j| q|D ]}	||	r\d}|| |j| qIqt|tjrl|jj}
|j}n]t|tjrz|jj}
|j}nOt|tjr|jj}
|j}nAt|tjr|jj}
n6t|tjr|j}
|j}n)t|tjr|jrd}q|j}
nt|tjrd}|jj}
nt|tjr|jj}
nq|r|d d |jd	 k rg }d
d |D }t|
tr| jr|
 |d}
d}| jrt!d|
 }
nt"d|
 }
| #|
|jd	 |D ]}|V  d}q	|rg }d}|r$| $|E d H  qd S )NFr   asciiz\s+zcomment-tagsTr      c                 S   s   g | ]}|d  qS )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   






zMessageExtractor.extract_nodesc                    s    fdd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qS 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   

zMessageExtractor._split_commentN)__name__
__module____qualname__r;   r   r   staticmethodr)   r   r   r   r   r      s    br   )ior   r   r    makor   r   r   r   r   r   r   <module>   s   