stylist
stylist copied to clipboard
Reporting invalid configuration extensions
If an invalid configuration file - e.g. a .txt file rather than a .py file - is passed to the CLI using the -configuration argument, the command reports that it is unable to find the file:
linux> touch empty.txt
linux> python -m stylist -configuration empty.txt check_nan_inf_mod.f90
Traceback (most recent call last):
File "/net/project/ukmo/scitools/opt_scitools/conda/deployments/default-2023_05_04/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/net/project/ukmo/scitools/opt_scitools/conda/deployments/default-2023_05_04/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/var/tmp/persistent/stylist/source/stylist/__main__.py", line 203, in <module>
main()
File "/var/tmp/persistent/stylist/source/stylist/__main__.py", line 189, in main
configuration = __configure(arguments.configuration)
File "/var/tmp/persistent/stylist/source/stylist/__main__.py", line 111, in __configure
configuration = load_configuration(project_file)
File "/var/tmp/persistent/stylist/source/stylist/configuration.py", line 53, in load_configuration
raise StylistException(message)
stylist.StylistException: Unable to find configuration file: empty.txt
linux>
It would be better if the error indicated that the the file was invalid rather than reporting that it could not be found. This was spotted during testing for PR 123.