mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-01-31 02:01:16 +00:00
utils/serializer: Handle empty file extensions
The ValueError does not given enough information in the case of an empty file extension. Add a special case to handle files with no extension and prompt the user.
This commit is contained in:
parent
88731fe489
commit
578d2d3a16
@ -299,6 +299,12 @@ def load(s, fmt='json', *args, **kwargs):
|
||||
def _read_pod(fh, fmt=None):
|
||||
if fmt is None:
|
||||
fmt = os.path.splitext(fh.name)[1].lower().strip('.')
|
||||
if fmt == '':
|
||||
# Special case of no given file extension
|
||||
message = ("Could not determine format " +
|
||||
"from file extension for \"{}\". ".format(getattr(fh, 'name', '<none>')) +
|
||||
"Please specify it or modify the fmt parameter.")
|
||||
raise ValueError(message)
|
||||
if fmt == 'yaml':
|
||||
return yaml.load(fh)
|
||||
elif fmt == 'json':
|
||||
|
Loading…
x
Reference in New Issue
Block a user