Merge pull request #97 from pubs/fix/config
Fix defaults not used in config.
This commit is contained in:
commit
4ea9f2101d
@ -21,6 +21,7 @@ class ConfigurationNotFound(IOError):
|
|||||||
|
|
||||||
def post_process_conf(conf):
|
def post_process_conf(conf):
|
||||||
"""Do some post processing on the configuration"""
|
"""Do some post processing on the configuration"""
|
||||||
|
check_conf(conf)
|
||||||
if conf['main']['docsdir'] == 'docsdir://':
|
if conf['main']['docsdir'] == 'docsdir://':
|
||||||
conf['main']['docsdir'] = os.path.join(conf['main']['pubsdir'], 'doc')
|
conf['main']['docsdir'] = os.path.join(conf['main']['pubsdir'], 'doc')
|
||||||
return conf
|
return conf
|
||||||
@ -29,8 +30,6 @@ def post_process_conf(conf):
|
|||||||
def load_default_conf():
|
def load_default_conf():
|
||||||
"""Load the default configuration"""
|
"""Load the default configuration"""
|
||||||
default_conf = configobj.ConfigObj(configspec=configspec)
|
default_conf = configobj.ConfigObj(configspec=configspec)
|
||||||
validator = validate.Validator()
|
|
||||||
default_conf.validate(validator, copy=True)
|
|
||||||
default_conf = post_process_conf(default_conf)
|
default_conf = post_process_conf(default_conf)
|
||||||
return default_conf
|
return default_conf
|
||||||
|
|
||||||
@ -54,8 +53,8 @@ def get_confpath(verify=True):
|
|||||||
def check_conf(conf):
|
def check_conf(conf):
|
||||||
"""Type check a configuration"""
|
"""Type check a configuration"""
|
||||||
validator = validate.Validator()
|
validator = validate.Validator()
|
||||||
results = conf.validate(validator, copy=True)
|
results = conf.validate(validator, copy=True)
|
||||||
assert results == True, '{}'.format(results) # TODO: precise error dialog when parsing error
|
assert (results is True), '{}'.format(results) # TODO: precise error dialog when parsing error
|
||||||
|
|
||||||
|
|
||||||
def load_conf(path=None):
|
def load_conf(path=None):
|
||||||
@ -64,8 +63,7 @@ def load_conf(path=None):
|
|||||||
path = get_confpath(verify=True)
|
path = get_confpath(verify=True)
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
raise ConfigurationNotFound(path)
|
raise ConfigurationNotFound(path)
|
||||||
with open(path, 'rb') as f:
|
conf = configobj.ConfigObj(path, configspec=configspec)
|
||||||
conf = configobj.ConfigObj(f.readlines(), configspec=configspec)
|
|
||||||
conf.filename = path
|
conf.filename = path
|
||||||
conf = post_process_conf(conf)
|
conf = post_process_conf(conf)
|
||||||
return conf
|
return conf
|
||||||
|
@ -55,7 +55,6 @@ def execute(raw_args=sys.argv):
|
|||||||
if update.update_check(conf, path=conf.filename):
|
if update.update_check(conf, path=conf.filename):
|
||||||
# an update happened, reload conf.
|
# an update happened, reload conf.
|
||||||
conf = config.load_conf(path=conf_path)
|
conf = config.load_conf(path=conf_path)
|
||||||
config.check_conf(conf)
|
|
||||||
except config.ConfigurationNotFound:
|
except config.ConfigurationNotFound:
|
||||||
if len(remaining_args) == 0 or remaining_args[0] == 'init':
|
if len(remaining_args) == 0 or remaining_args[0] == 'init':
|
||||||
conf = config.load_default_conf()
|
conf = config.load_default_conf()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user