mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-10-05 18:50:09 +02:00
log error if config file name is not known
The case of Anti-Features keys and filenames is quite confusing. I was confused to find out that config/antiFeatures.yml is correct, while config/antifeatures.yml is nothing. This throws an error message to make that clear.
This commit is contained in:
parent
4e28fad55a
commit
9df8caca07
@ -28,6 +28,7 @@
|
||||
# common.py is imported by all modules, so do not import third-party
|
||||
# libraries here as they will become a requirement for all commands.
|
||||
|
||||
import difflib
|
||||
import git
|
||||
import glob
|
||||
import io
|
||||
@ -519,7 +520,9 @@ def load_localized_config(name, repodir):
|
||||
|
||||
"""
|
||||
ret = dict()
|
||||
found_config_file = False
|
||||
for f in Path().glob("config/**/{name}.yml".format(name=name)):
|
||||
found_config_file = True
|
||||
locale = f.parts[1]
|
||||
if len(f.parts) == 2:
|
||||
locale = DEFAULT_LOCALE
|
||||
@ -542,6 +545,16 @@ def load_localized_config(name, repodir):
|
||||
else:
|
||||
ret[afname][key][locale] = value
|
||||
|
||||
if not found_config_file:
|
||||
for f in Path().glob("config/*.yml"):
|
||||
if f.stem not in CONFIG_NAMES:
|
||||
msg = _('{path} is not a standard config file!').format(path=f)
|
||||
m = difflib.get_close_matches(f.stem, CONFIG_NAMES, 1)
|
||||
if m:
|
||||
msg += ' '
|
||||
msg += _('Did you mean config/{name}.yml?').format(name=m[0])
|
||||
logging.error(msg)
|
||||
|
||||
for elem in ret.values():
|
||||
for afname in elem:
|
||||
elem[afname] = {locale: v for locale, v in sorted(elem[afname].items())}
|
||||
|
Loading…
Reference in New Issue
Block a user