mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-05 15:00:30 +03:00
srclibs: forward yml parsing error cause
This commit is contained in:
parent
ee3d8d2f18
commit
aa020af040
1 changed files with 8 additions and 4 deletions
|
|
@ -42,12 +42,15 @@ srclibs = None
|
||||||
warnings_action = None
|
warnings_action = None
|
||||||
|
|
||||||
|
|
||||||
def warn_or_exception(value):
|
def warn_or_exception(value, cause=None):
|
||||||
'''output warning or Exception depending on -W'''
|
'''output warning or Exception depending on -W'''
|
||||||
if warnings_action == 'ignore':
|
if warnings_action == 'ignore':
|
||||||
pass
|
pass
|
||||||
elif warnings_action == 'error':
|
elif warnings_action == 'error':
|
||||||
raise MetaDataException(value)
|
if cause:
|
||||||
|
raise MetaDataException(value) from cause
|
||||||
|
else:
|
||||||
|
raise MetaDataException(value)
|
||||||
else:
|
else:
|
||||||
logging.warning(value)
|
logging.warning(value)
|
||||||
|
|
||||||
|
|
@ -763,14 +766,15 @@ def parse_yml_srclib(metadatapath):
|
||||||
except yaml.error.YAMLError as e:
|
except yaml.error.YAMLError as e:
|
||||||
warn_or_exception(_("Invalid srclib metadata: could not "
|
warn_or_exception(_("Invalid srclib metadata: could not "
|
||||||
"parse '{file}'"
|
"parse '{file}'"
|
||||||
.format(file=metadatapath)))
|
.format(file=metadatapath)),
|
||||||
|
e)
|
||||||
return thisinfo
|
return thisinfo
|
||||||
|
|
||||||
for key in data.keys():
|
for key in data.keys():
|
||||||
if key not in thisinfo.keys():
|
if key not in thisinfo.keys():
|
||||||
warn_or_exception(_("Invalid srclib metadata: unknown key "
|
warn_or_exception(_("Invalid srclib metadata: unknown key "
|
||||||
"'{key}' in '{file}'")
|
"'{key}' in '{file}'")
|
||||||
.format(key=key, file=metadatapath))
|
.format(key=key, file=metadatapath))
|
||||||
return thisinfo
|
return thisinfo
|
||||||
else:
|
else:
|
||||||
if key == 'Subdir':
|
if key == 'Subdir':
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue