Update filter and handle nested quotes
This commit is contained in:
parent
3123cc69c4
commit
1835f1ab14
@ -75,6 +75,7 @@ def qstr_unescape(qstr):
|
|||||||
def process_file(f):
|
def process_file(f):
|
||||||
re_line = re.compile(r"#[line]*\s(\d+)\s\"([^\"]+)\"")
|
re_line = re.compile(r"#[line]*\s(\d+)\s\"([^\"]+)\"")
|
||||||
re_qstr = re.compile(r'MP_QSTR_[_a-zA-Z0-9]+')
|
re_qstr = re.compile(r'MP_QSTR_[_a-zA-Z0-9]+')
|
||||||
|
re_translate = re.compile(r'translate\(\"((?:(?=(\\?))\2.)*?)\"\)')
|
||||||
output = []
|
output = []
|
||||||
last_fname = None
|
last_fname = None
|
||||||
lineno = 0
|
lineno = 0
|
||||||
@ -99,8 +100,8 @@ def process_file(f):
|
|||||||
name = match.replace('MP_QSTR_', '')
|
name = match.replace('MP_QSTR_', '')
|
||||||
if name not in QSTRING_BLACK_LIST:
|
if name not in QSTRING_BLACK_LIST:
|
||||||
output.append('Q(' + qstr_unescape(name) + ')')
|
output.append('Q(' + qstr_unescape(name) + ')')
|
||||||
for match in re.findall(r'translate\(\"([^\"]+)\"\)', line):
|
for match in re_translate.findall(line):
|
||||||
output.append('TRANSLATE("' + match + '")')
|
output.append('TRANSLATE("' + match[0] + '")')
|
||||||
lineno += 1
|
lineno += 1
|
||||||
|
|
||||||
write_out(last_fname, output)
|
write_out(last_fname, output)
|
||||||
|
@ -79,7 +79,7 @@ $(OBJ): | $(HEADER_BUILD)/qstrdefs.enum.h $(HEADER_BUILD)/mpversion.h
|
|||||||
# - else, process all source files ($^) [this covers "make -B" which can set $? to empty]
|
# - else, process all source files ($^) [this covers "make -B" which can set $? to empty]
|
||||||
$(HEADER_BUILD)/qstr.i.last: $(SRC_QSTR) $(SRC_QSTR_PREPROCESSOR) $(QSTR_GLOBAL_DEPENDENCIES) | $(HEADER_BUILD)/mpversion.h
|
$(HEADER_BUILD)/qstr.i.last: $(SRC_QSTR) $(SRC_QSTR_PREPROCESSOR) $(QSTR_GLOBAL_DEPENDENCIES) | $(HEADER_BUILD)/mpversion.h
|
||||||
$(STEPECHO) "GEN $@"
|
$(STEPECHO) "GEN $@"
|
||||||
$(Q)grep -lE "(MP_QSTR|i18n)" $(if $(filter $?,$(QSTR_GLOBAL_DEPENDENCIES)),$^,$(if $?,$?,$^)) | xargs $(CPP) $(QSTR_GEN_EXTRA_CFLAGS) $(CFLAGS) $(SRC_QSTR_PREPROCESSOR) >$(HEADER_BUILD)/qstr.i.last;
|
$(Q)grep -lE "(MP_QSTR|translate)" $(if $(filter $?,$(QSTR_GLOBAL_DEPENDENCIES)),$^,$(if $?,$?,$^)) | xargs $(CPP) $(QSTR_GEN_EXTRA_CFLAGS) $(CFLAGS) $(SRC_QSTR_PREPROCESSOR) >$(HEADER_BUILD)/qstr.i.last;
|
||||||
|
|
||||||
$(HEADER_BUILD)/qstr.split: $(HEADER_BUILD)/qstr.i.last $(PY_SRC)/makeqstrdefs.py
|
$(HEADER_BUILD)/qstr.split: $(HEADER_BUILD)/qstr.i.last $(PY_SRC)/makeqstrdefs.py
|
||||||
$(STEPECHO) "GEN $@"
|
$(STEPECHO) "GEN $@"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user