Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(25)  |  Call(24)  |  Derive(0)  |  Import(1)
Extract messages from Obviel Template (.obvt) source code.

:param fileobj: the seekable, 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(more...)

        def extractor(fileobj, keywords, comment_tags, options):
    """Extract messages from Obviel Template (.obvt) source code.

    :param fileobj: the seekable, 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``
    """
    tree = html.parse(fileobj)
    for el in tree.xpath('//*[@data-trans]'):
        for message_id in trans_message_ids(el):
            funcname, message_id = pluralize(message_id)
            yield (el.sourceline, funcname, message_id, [])
    for el in tree.xpath('//*[@data-tvar]'):
        message_id  = tvar_message_id(el)
        if message_id is not None:
            funcname, message_id = pluralize(message_id)
            yield (el.sourceline, funcname, message_id, [])
        


src/b/a/babel-obviel-0.7.1/babelobviel/test/test_extractor.py   babel-obviel(Download)
from babelobviel.obvt import extractor, html_extractor
import os
 
def datafile(name):
    return os.path.join(os.path.dirname(__file__), 'testdata', name)
 
def test_text():
    with open(datafile('test1.obvt')) as f:
        r = list(extractor(f, [], [], []))
def test_text_explicit():
    with open(datafile('test2.obvt')) as f:
        r = list(extractor(f, [], [], []))
        assert len(r) == 1
        lineno, funcname, message, comments = r[0]
def test_text_message_id():
    with open(datafile('test3.obvt')) as f:
        r = list(extractor(f, [], [], []))
        assert len(r) == 1
        lineno, funcname, message, comments = r[0]
def test_text_message_id_explicit():
    with open(datafile('test4.obvt')) as f:
        r = list(extractor(f, [], [], []))
        assert len(r) == 1
        lineno, funcname, message, comments = r[0]