a
    e	g                     @   sV   d dl Z d dl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)MessageExtractorc                   @   s6   e Zd ZdZdZdgZdddZddd	Zd
d ZdS )LinguaMakoExtractorzMako templatesFz.makozutf-8 )encodingzcomment-tagsNc                 c   sl   || _ || _td| _|d u r*t|d}n
t|}| }| |E d H  W d    n1 s^0    Y  d S )Nzx.pyr)optionsfilenamer   python_extractoropen
contextlibnullcontextZprocess_file)selfr   r
   fileobjctxfile_ r   X/var/www/html/llm_bihealth/app/venv/lib/python3.9/site-packages/mako/ext/linguaplugin.py__call__   s    

zLinguaMakoExtractor.__call__c              
   c   s   |   }|drL|dv s(|dr.d}n|drD|dd  }|d7 }t|}| | j| j||d D ]<}|rt	|j
|j|j|jd	||jg |j|j}|V  qnd S )
N:)ztry:zelse:exceptr   elif   pass    )getvaluestripendswith
startswithioStringIOr   r   r
   r   ZmsgctxtmsgidZmsgid_pluralflags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__	use_bytes
extensionsZdefault_configr   r,   r   r   r   r   r      s   

r   )	r   r"   Zlingua.extractorsr   r   r   Zmako.ext.extractr   r   r   r   r   r   <module>   s   