mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-04 22:40:29 +03: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
1 changed files with 13 additions and 0 deletions
|
|
@ -28,6 +28,7 @@
|
||||||
# common.py is imported by all modules, so do not import third-party
|
# common.py is imported by all modules, so do not import third-party
|
||||||
# libraries here as they will become a requirement for all commands.
|
# libraries here as they will become a requirement for all commands.
|
||||||
|
|
||||||
|
import difflib
|
||||||
import git
|
import git
|
||||||
import glob
|
import glob
|
||||||
import io
|
import io
|
||||||
|
|
@ -519,7 +520,9 @@ def load_localized_config(name, repodir):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
ret = dict()
|
ret = dict()
|
||||||
|
found_config_file = False
|
||||||
for f in Path().glob("config/**/{name}.yml".format(name=name)):
|
for f in Path().glob("config/**/{name}.yml".format(name=name)):
|
||||||
|
found_config_file = True
|
||||||
locale = f.parts[1]
|
locale = f.parts[1]
|
||||||
if len(f.parts) == 2:
|
if len(f.parts) == 2:
|
||||||
locale = DEFAULT_LOCALE
|
locale = DEFAULT_LOCALE
|
||||||
|
|
@ -542,6 +545,16 @@ def load_localized_config(name, repodir):
|
||||||
else:
|
else:
|
||||||
ret[afname][key][locale] = value
|
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 elem in ret.values():
|
||||||
for afname in elem:
|
for afname in elem:
|
||||||
elem[afname] = {locale: v for locale, v in sorted(elem[afname].items())}
|
elem[afname] = {locale: v for locale, v in sorted(elem[afname].items())}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue