2 # EASY-INSTALL-ENTRY-SCRIPT: 'Babel==0.9.6','console_scripts','pybabel'
3 __requires__ = 'Babel==0.9.6'
5 from pkg_resources import load_entry_point
8 import xml.etree.ElementTree as elt
10 if __name__ == '__main__':
12 load_entry_point('Babel==0.9.6', 'console_scripts', 'pybabel')()
15 XMLJS_EXPR = re.compile(r"""(?:\_t *\( *((?:"(?:[^"\\]|\\.)*")|(?:'(?:[^'\\]|\\.)*')) *\))""")
17 def extract_xmljs(fileobj, keywords, comment_tags, options):
18 content = fileobj.read()
19 found = XMLJS_EXPR.finditer(content)
26 while index < f.start():
27 if content[index] == "\n":
30 result.append((line_nbr, None, mes, ""))
33 def extract_qweb(fileobj, keywords, comment_tags, options):
34 """Extract messages from XXX files.
35 :param fileobj: the file-like object the messages should be extracted
37 :param keywords: a list of keywords (i.e. function names) that should
38 be recognized as translation functions
39 :param comment_tags: a list of translator tags to search for and
40 include in the results
41 :param options: a dictionary of additional options (optional)
42 :return: an iterator over ``(lineno, funcname, message, comments)``
48 str = (str or "").strip()
51 result.append((0, None, str, ""))
53 def iter_elements(current_element):
54 for el in current_element:
55 if "t-js" not in el.attrib and \
56 not ("t-jquery" in el.attrib and "t-operation" not in el.attrib) and \
57 not ("t-trad" in el.attrib and el.attrib["t-trad"].strip() == "off"):
62 tree = elt.parse(fileobj)
63 iter_elements(tree.getroot())