o
    4c                     @   s@   d dl Z d dlmZ d dlmZ d dlmZ G dd deZdS )    N)compat)lexer)	parsetreec                   @   s(   e Zd Zdd Zdd Zedd ZdS )MessageExtractorc                 c   s<    t j| | jd d }| | D ]}|V  qd S )Nencoding)input_encoding)r   Lexerreadconfigparseextract_nodesget_children)selffileobjtemplate_node	extracted r   F/var/www/html/gps/gps/lib/python3.10/site-packages/mako/ext/extract.pyprocess_file   s   zMessageExtractor.process_filec                 c   sF   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jr|
 |d}
d}t!t"d|
 }
| #|
|jd	 |D ]}|V  d}q|rg }d}|r | $|D ]}|V  qqd S )NFr   asciiz\s+zcomment-tagsTr      c                 S   s   g | ]}|d  qS )r   r   ).0commentr   r   r   
<listcomp>Y   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
Expressionr   	text_typeencodebyte_bufferb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   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   z   s    
z3MessageExtractor._split_comment.<locals>.<listcomp>)	enumerate
splitlines)r)   r   r   rJ   r   r(   v   s   

zMessageExtractor._split_commentN)__name__
__module____qualname__r   r   staticmethodr(   r   r   r   r   r      s
    `r   )r   makor   r   r   objectr   r   r   r   r   <module>   s
   