mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-06-16 15:22:17 +03:00
Dont overwrite template files when generating new ones
This commit is contained in:
parent
54c8558d35
commit
dbc357ebcd
19
l10n.py
19
l10n.py
@ -11,7 +11,7 @@ import sys
|
|||||||
import warnings
|
import warnings
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
from os.path import basename, dirname, exists, isdir, isfile, join
|
from os.path import basename, dirname, isdir, isfile, join
|
||||||
from sys import platform
|
from sys import platform
|
||||||
from typing import TYPE_CHECKING, Dict, Iterable, Optional, Set, TextIO, Union, cast
|
from typing import TYPE_CHECKING, Dict, Iterable, Optional, Set, TextIO, Union, cast
|
||||||
|
|
||||||
@ -357,7 +357,7 @@ if __name__ == "__main__":
|
|||||||
import re
|
import re
|
||||||
regexp = re.compile(r'''_\([ur]?(['"])(((?<!\\)\\\1|.)+?)\1\)[^#]*(#.+)?''') # match a single line python literal
|
regexp = re.compile(r'''_\([ur]?(['"])(((?<!\\)\\\1|.)+?)\1\)[^#]*(#.+)?''') # match a single line python literal
|
||||||
seen: Dict[str, str] = {}
|
seen: Dict[str, str] = {}
|
||||||
for f in ( # TODO: need to be sorted and then concatted like this?
|
for f in (
|
||||||
sorted(x for x in os.listdir('.') if x.endswith('.py')) +
|
sorted(x for x in os.listdir('.') if x.endswith('.py')) +
|
||||||
sorted(join('plugins', x) for x in (os.listdir('plugins') if isdir('plugins') else []) if x.endswith('.py'))
|
sorted(join('plugins', x) for x in (os.listdir('plugins') if isdir('plugins') else []) if x.endswith('.py'))
|
||||||
):
|
):
|
||||||
@ -371,15 +371,12 @@ if __name__ == "__main__":
|
|||||||
(match.group(4) and (match.group(4)[1:].strip()) + '. ' or '') + f'[{basename(f)}]'
|
(match.group(4) and (match.group(4)[1:].strip()) + '. ' or '') + f'[{basename(f)}]'
|
||||||
)
|
)
|
||||||
if seen:
|
if seen:
|
||||||
if not isdir(LOCALISATION_DIR):
|
target_path = pathlib.Path(LOCALISATION_DIR) / 'en.template.new'
|
||||||
os.mkdir(LOCALISATION_DIR)
|
target_path.mkdir(exist_ok=True)
|
||||||
|
with target_path.open('w', encoding='utf-8') as target_file:
|
||||||
template = open(join(LOCALISATION_DIR, 'en.template'), 'w', encoding='utf-8')
|
target_file.write(f'/* Language name */\n"{LANGUAGE_ID}" = "English";\n\n')
|
||||||
template.write(f'/* Language name */\n"{LANGUAGE_ID}" = "English";\n\n')
|
|
||||||
for thing in sorted(seen, key=str.lower):
|
for thing in sorted(seen, key=str.lower):
|
||||||
if seen[thing]:
|
if seen[thing]:
|
||||||
template.write(f'/* {seen[thing]} */\n')
|
target_file.write(f'/* {seen[thing]} */\n')
|
||||||
|
|
||||||
template.write(f'"{thing}" = "{thing}";\n\n')
|
target_file.write(f'"{thing}" = "{thing}";\n\n')
|
||||||
|
|
||||||
template.close()
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user