diff options
| author | Scott Shawcroft <scott@tannewt.org> | 2018-08-09 14:16:28 -0700 |
|---|---|---|
| committer | Scott Shawcroft <scott@tannewt.org> | 2018-08-09 14:16:28 -0700 |
| commit | 1835f1ab14d2532684224d1eccaa5d219b296878 (patch) | |
| tree | 6802f6482c56d9181811fc080481676d72fc9879 /py/makeqstrdefs.py | |
| parent | 3123cc69c4a860507e2e7304a3e4dc67c4caa9c8 (diff) | |
Update filter and handle nested quotes
Diffstat (limited to 'py/makeqstrdefs.py')
| -rw-r--r-- | py/makeqstrdefs.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/py/makeqstrdefs.py b/py/makeqstrdefs.py index 06cf9078a..cb27ced35 100644 --- a/py/makeqstrdefs.py +++ b/py/makeqstrdefs.py @@ -75,6 +75,7 @@ def qstr_unescape(qstr): def process_file(f): re_line = re.compile(r"#[line]*\s(\d+)\s\"([^\"]+)\"") re_qstr = re.compile(r'MP_QSTR_[_a-zA-Z0-9]+') + re_translate = re.compile(r'translate\(\"((?:(?=(\\?))\2.)*?)\"\)') output = [] last_fname = None lineno = 0 @@ -99,8 +100,8 @@ def process_file(f): name = match.replace('MP_QSTR_', '') if name not in QSTRING_BLACK_LIST: output.append('Q(' + qstr_unescape(name) + ')') - for match in re.findall(r'translate\(\"([^\"]+)\"\)', line): - output.append('TRANSLATE("' + match + '")') + for match in re_translate.findall(line): + output.append('TRANSLATE("' + match[0] + '")') lineno += 1 write_out(last_fname, output) |
