mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-21 17:51:03 +00:00
lyx_pot.py: Fix regex for \Format
Each token could be delimited by quotation marks or not. The previous regexes only considered this for two tokens and hence produced wrong matches for cases such as \Format gnuplot "gp, gnuplot, plt" "Gnuplot" "" "" "" "vector" "text/plain" where the extension list wasn't parsed as a single token.
This commit is contained in:
parent
337a94a425
commit
1efdc11296
@ -572,18 +572,15 @@ def external_l10n(input_files, output, base):
|
|||||||
def formats_l10n(input_files, output, base):
|
def formats_l10n(input_files, output, base):
|
||||||
'''Generate pot file from configure.py'''
|
'''Generate pot file from configure.py'''
|
||||||
output = io.open(output, 'w', encoding='utf_8', newline='\n')
|
output = io.open(output, 'w', encoding='utf_8', newline='\n')
|
||||||
GuiName = re.compile(r'.*\\Format\s+\S+\s+\S+\s+"([^"]*)"\s+(\S*)\s+.*', re.IGNORECASE)
|
# \Format "shortname" "ext1, ext2..." "name" "shortcut" (quotation marks optional in each group)
|
||||||
GuiName2 = re.compile(r'.*\\Format\s+\S+\s+\S+\s+([^"]\S+)\s+(\S*)\s+.*', re.IGNORECASE)
|
GuiName = re.compile(r'.*\\Format\s+(""|"[^"]+"|\S+)\s+(""|"[^"]+"|\S+)\s+(""|"[^"]+"|\S+)\s+(""|"[^"]+"|\S+)\s+.*', re.IGNORECASE)
|
||||||
input = io.open(input_files[0], encoding='utf_8')
|
input = io.open(input_files[0], encoding='utf_8')
|
||||||
for lineno, line in enumerate(input.readlines()):
|
for lineno, line in enumerate(input.readlines()):
|
||||||
label = ""
|
label = ""
|
||||||
labelsc = ""
|
labelsc = ""
|
||||||
if GuiName.match(line):
|
if GuiName.match(line):
|
||||||
label = GuiName.match(line).group(1)
|
label = GuiName.match(line).group(3)
|
||||||
shortcut = GuiName.match(line).group(2).replace('"', '')
|
shortcut = GuiName.match(line).group(4).replace('"', '')
|
||||||
elif GuiName2.match(line):
|
|
||||||
label = GuiName2.match(line).group(1)
|
|
||||||
shortcut = GuiName2.match(line).group(2).replace('"', '')
|
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
label = label.replace('\\', '\\\\').replace('"', '')
|
label = label.replace('\\', '\\\\').replace('"', '')
|
||||||
|
Loading…
Reference in New Issue
Block a user