Structure conversion now improved so that it matches correctly
This commit is contained in:
parent
c4938b5785
commit
b485fb173f
|
@ -22,12 +22,10 @@ def build_structure_conversions():
|
||||||
if line[1] == "struktura":
|
if line[1] == "struktura":
|
||||||
continue
|
continue
|
||||||
|
|
||||||
vfrom = line[0].replace("?", "\?").replace("%s", "([a-zA-Z螚ȎŠ-]+)")
|
vfrom = "^" + line[0].replace("?", "\?").replace("%s", "([a-zA-Z螚ȎŠ-]+)") + "$"
|
||||||
vmatch = "^" + vfrom + "$"
|
|
||||||
vto = line[1].replace("<struktura>", "").replace("</struktura>", "").replace("%s", "$1").strip()
|
vto = line[1].replace("<struktura>", "").replace("</struktura>", "").replace("%s", "$1").strip()
|
||||||
|
|
||||||
structure_conversions.append((__new__(RegExp(vmatch, 'u')),
|
structure_conversions.append((__new__(RegExp(vfrom, 'u')),
|
||||||
__new__(RegExp(vfrom, 'u')),
|
|
||||||
vto))
|
vto))
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,10 +33,17 @@ def convert_structure(structure):
|
||||||
if structure_conversions is None:
|
if structure_conversions is None:
|
||||||
build_structure_conversions()
|
build_structure_conversions()
|
||||||
|
|
||||||
for vmatch, vfrom, vto in structure_conversions:
|
for vfrom, vto in structure_conversions:
|
||||||
if vmatch.test(structure):
|
match = structure.match(vfrom)
|
||||||
|
if match:
|
||||||
# we need to remove replace alias here as we want to use javascript's one
|
# we need to remove replace alias here as we want to use javascript's one
|
||||||
__pragma__('noalias', 'replace')
|
__pragma__('noalias', 'replace')
|
||||||
return structure.replace(vfrom, vto).strip()
|
result = structure.replace(vfrom, vto).strip()
|
||||||
|
__pragma__('alias', 'replace', "py_replace")
|
||||||
|
|
||||||
|
# they said this also needs to be done - remove "-d$" from %s match
|
||||||
|
if len(match) > 1 and match[1].endswith("-d"):
|
||||||
|
result = result.replace(match[1], match[1][:-2])
|
||||||
|
return result
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
Loading…
Reference in New Issue
Block a user