Commit 3de20708 authored by Médéric Boquien's avatar Médéric Boquien

Add a test to ensure that we are always in a situation where we can generate a...

Add a test to ensure that we are always in a situation where we can generate a valid pcigale.ini.spec file, otherwise raise en exception.
parent 370142cd
Pipeline #2870 skipped with stage
......@@ -3,6 +3,7 @@
## Unreleased
### Added
- The polar dust model of X-CIGALE (Yang et al., 2020) for the `skirtor2016` module has been integrated into the regular version. (Médéric Boquien, based on the initial work of Guang Yang)
- An additional check is done when constructing the `pcigale.ini` and `pcigale.ini.spec` files to avoid the generation of an incorrect `pcigale.ini.spec` when `pcigale.ini` exists but `pcigale.ini.spec` does not, which is not supposed to happen under regular circumstances. (Médéric Boquien)
### Changed
### Fixed
- Ensure that `pcigale-plots` correctly detects the `skirtor2016` AGN models. (Médéric Boquien, reported by Guang Yang)
......
......@@ -36,17 +36,28 @@ class Configuration(object):
Name of the configuration file (pcigale.conf by default).
"""
self.spec = configobj.ConfigObj(filename+'.spec',
write_empty_values=True,
indent_type=' ',
encoding='UTF8',
list_values=False,
_inspec=True)
self.config = configobj.ConfigObj(filename,
write_empty_values=True,
indent_type=' ',
encoding='UTF8',
configspec=self.spec)
# We should never be in the case when there is a pcigale.ini but no
# pcigale.ini.spec. While this seems to work when doing the pcigale
# genconf, it actually generates an incorrect pcigale.ini.spec. The only
# clean solution is to rebuild both files.
if os.path.isfile(filename) and not os.path.isfile(filename+'.spec'):
raise Exception("The pcigale.ini.spec file appears to be missing. "
"Please delete the pcigale.ini file and regenrate "
"it with 'pcigale init' and then 'pcigale genconf' "
"after having filled the initial pcigale.ini "
"template.")
else:
self.spec = configobj.ConfigObj(filename+'.spec',
write_empty_values=True,
indent_type=' ',
encoding='UTF8',
list_values=False,
_inspec=True)
self.config = configobj.ConfigObj(filename,
write_empty_values=True,
indent_type=' ',
encoding='UTF8',
configspec=self.spec)
# We validate the configuration so that the variables are converted to
# the expected that. We do not handle errors at the point but only when
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment