a
    e	g+                     @   s8   d Z ddlmZ ddlmZ G dd deZdd ZdS )	zEgettext message extraction via Babel: https://pypi.org/project/Babel/    )extract_python)MessageExtractorc                       s,   e Zd Z fddZdd Zdd Z  ZS )BabelMakoExtractorc                    s<   || _ || _d||d|dd d| _t   d S )N Zinput_encodingencoding)comment-tagsr   )keywordsoptionsjoingetconfigsuper__init__)selfr   comment_tagsr	   	__class__ W/var/www/html/llm_bihealth/app/venv/lib/python3.9/site-packages/mako/ext/babelplugin.pyr      s    zBabelMakoExtractor.__init__c                 C   s
   |  |S )N)Zprocess_file)r   fileobjr   r   r   __call__   s    zBabelMakoExtractor.__call__c           	      c   sH   | j d }t|| j|| jD ]&\}}}}||d  |||| fV  qd S )Nr      )r   r   r   r	   )	r   codeZcode_linenoZtranslator_stringsr   linenofuncnamemessagesZpython_translator_commentsr   r   r   process_python   s    

z!BabelMakoExtractor.process_python)__name__
__module____qualname__r   r   r   __classcell__r   r   r   r   r      s   r   c                 c   s   t |||}|| E dH  dS )a  Extract messages from Mako templates.

    :param fileobj: the file-like object the messages should be extracted from
    :param keywords: a list of keywords (i.e. function names) that should be
                     recognized as translation functions
    :param comment_tags: a list of translator tags to search for and include
                         in the results
    :param options: a dictionary of additional options (optional)
    :return: an iterator over ``(lineno, funcname, message, comments)`` tuples
    :rtype: ``iterator``
    N)r   )r   r   r   r	   Z	extractorr   r   r   extract,   s    r!   N)__doc__Zbabel.messages.extractr   Zmako.ext.extractr   r   r!   r   r   r   r   <module>   s   