@ -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
@ -55,7 +54,7 @@ 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