o
    ‹åg3  ã                   @   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   úL/var/www/html/flaskapp/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r¬d}q|j}
nt|tjƒr½d}|jj}
nt|tjƒrÈ|jj}
nq|rØ|d d |jd	 k rØg }d
d„ |D ƒ}t|
tƒrí| jrí|
  |d¡}
d}| jrùt!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-tagsTéÿÿÿÿr   é   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   