B
    è¹`q  ã               @   sZ   d dl Z d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ G dd„ deeƒZ	dS )	é    N)Ú	Extractor)Úget_extractor)ÚMessage)Úcompat)ÚMessageExtractorc               @   s2   e Zd ZdZdgZdddœZddd„Zd	d
„ ZdS )ÚLinguaMakoExtractorzMako templatesz.makozutf-8Ú )Úencodingzcomment-tagsNc             c   sd   || _ || _tdƒ| _|d kr.t|dƒ}d}nd}zx|  |¡D ]
}|V  q@W W d |r^| ¡  X d S )Nzx.pyÚrbTF)ÚoptionsÚfilenamer   Úpython_extractorÚopenZprocess_fileÚclose)Úselfr   r   ÚfileobjZ
must_closeÚmessage© r   ú]/home/kop/projects/devel/pgwui/test_venv/lib/python3.7/site-packages/mako/ext/linguaplugin.pyÚ__call__   s    

zLinguaMakoExtractor.__call__c          
   c   sè   |  ¡  ¡ }| t d¡¡rz|t d¡t d¡fksD| t d¡¡rPt d¡}n| t d¡¡rl|dd … }|t d¡7 }t |¡}x^|  | j	| j
||d	 ¡D ]B}|rÚt|j|j|j|jt d
¡ ||jg ¡|j|jƒ}|V  qžW d S )Nú:ztry:zelse:Úexceptr   Úelifé   Úpassé   ú )ÚgetvalueÚstripÚendswithr   ÚbÚ
startswithÚioÚBytesIOr   r   r   r   ZmsgctxtÚmsgidZmsgid_pluralÚflagsÚuÚjoinÚcommentZtcommentÚlocation)r   ÚcodeZcode_linenoZtranslator_stringsÚsourceÚmsgr   r   r   Úprocess_python(   s.    
z"LinguaMakoExtractor.process_python)N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú
extensionsZdefault_configr   r-   r   r   r   r   r      s
   

r   )
r"   Zlingua.extractorsr   r   r   Zmakor   Zmako.ext.extractr   r   r   r   r   r   Ú<module>   s   