[imp] improved qweb scanning function
bzr revid: nicolas.vanhoren@openerp.com-20110816104219-wt0rl0kpfn5rcvz7
This commit is contained in:
parent
5b522f5d06
commit
be46b05129
16
npybabel.py
16
npybabel.py
|
@ -3,12 +3,15 @@
|
||||||
__requires__ = 'Babel==0.9.6'
|
__requires__ = 'Babel==0.9.6'
|
||||||
import sys
|
import sys
|
||||||
from pkg_resources import load_entry_point
|
from pkg_resources import load_entry_point
|
||||||
|
import re
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
sys.exit(
|
sys.exit(
|
||||||
load_entry_point('Babel==0.9.6', 'console_scripts', 'pybabel')()
|
load_entry_point('Babel==0.9.6', 'console_scripts', 'pybabel')()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
QWEB_EXPR = re.compile(r"""(?:\< *t\-tr *\>(.*?)\< *\/t\-tr *\>)|(?:\_t *\( *((?:\".*?\")|(?:\'.*?\')) *\))""")
|
||||||
|
|
||||||
def extract_qweb(fileobj, keywords, comment_tags, options):
|
def extract_qweb(fileobj, keywords, comment_tags, options):
|
||||||
"""Extract messages from XXX files.
|
"""Extract messages from XXX files.
|
||||||
:param fileobj: the file-like object the messages should be extracted
|
:param fileobj: the file-like object the messages should be extracted
|
||||||
|
@ -23,4 +26,15 @@ def extract_qweb(fileobj, keywords, comment_tags, options):
|
||||||
:rtype: ``iterator``
|
:rtype: ``iterator``
|
||||||
"""
|
"""
|
||||||
content = fileobj.read()
|
content = fileobj.read()
|
||||||
return []
|
found = QWEB_EXPR.finditer(content)
|
||||||
|
result = []
|
||||||
|
index = 0
|
||||||
|
line_nbr = 0
|
||||||
|
for f in found:
|
||||||
|
group = 1 if f.group(1) else 2
|
||||||
|
while index < f.start():
|
||||||
|
if content[index] == "\n":
|
||||||
|
line_nbr += 1
|
||||||
|
index += 1
|
||||||
|
result.append((line_nbr, None, f.group(group), ""))
|
||||||
|
return result
|
||||||
|
|
Loading…
Reference in New Issue