B
    è¹`Z  ã               @   s8   d Z ddlmZ ddlmZ G dd„ deƒZdd„ ZdS )	z@gettext message extraction via Babel: http://babel.edgewall.org/é    )Ú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t| ƒ ¡  d S )Nú Zinput_encodingÚencoding)zcomment-tagsr   )ÚkeywordsÚoptionsÚjoinÚgetÚconfigÚsuperr   Ú__init__)Úselfr   Úcomment_tagsr   )Ú	__class__© ú\/home/kop/projects/devel/pgwui/test_venv/lib/python3.7/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   sL   | j d }x<t|| j|| jƒD ]&\}}}}||d  |||| fV  qW d S )Nzcomment-tagsé   )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 |||ƒ}x|| ƒD ]
}|V  qW 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	extractorÚmessager   r   r   Úextract,   s    r    N)Ú__doc__Zbabel.messages.extractr   Zmako.ext.extractr   r   r    r   r   r   r   Ú<module>   s   