config.Config: add constructor parameter default_config_dirpath
This commit is contained in:
parent
c851e7aca7
commit
b90994037a
1 changed files with 7 additions and 2 deletions
|
@ -558,7 +558,7 @@ class Config: # pylint: disable=too-many-instance-attributes
|
||||||
""" Configuration helper """
|
""" Configuration helper """
|
||||||
|
|
||||||
def __init__(self, appname, shortname=None, version=None, encoding=None,
|
def __init__(self, appname, shortname=None, version=None, encoding=None,
|
||||||
config_file_env_variable=None):
|
config_file_env_variable=None, default_config_dirpath=None):
|
||||||
self.appname = appname
|
self.appname = appname
|
||||||
self.shortname = shortname
|
self.shortname = shortname
|
||||||
self.version = version if version else '0.0'
|
self.version = version if version else '0.0'
|
||||||
|
@ -571,6 +571,7 @@ class Config: # pylint: disable=too-many-instance-attributes
|
||||||
self._loaded_callbacks_executed = []
|
self._loaded_callbacks_executed = []
|
||||||
self._filepath = None
|
self._filepath = None
|
||||||
self.config_file_env_variable = config_file_env_variable
|
self.config_file_env_variable = config_file_env_variable
|
||||||
|
self.default_config_dirpath = default_config_dirpath
|
||||||
|
|
||||||
def add_section(self, name, loaded_callback=None, **kwargs):
|
def add_section(self, name, loaded_callback=None, **kwargs):
|
||||||
"""
|
"""
|
||||||
|
@ -934,7 +935,11 @@ class Config: # pylint: disable=too-many-instance-attributes
|
||||||
@property
|
@property
|
||||||
def config_dir(self):
|
def config_dir(self):
|
||||||
""" Retrieve configuration directory path """
|
""" Retrieve configuration directory path """
|
||||||
return os.path.dirname(self._filepath) if self._filepath else DEFAULT_CONFIG_DIRPATH
|
if self._filepath:
|
||||||
|
return os.path.dirname(self._filepath)
|
||||||
|
if self.default_config_dirpath:
|
||||||
|
return self.default_config_dirpath
|
||||||
|
return DEFAULT_CONFIG_DIRPATH
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def config_filepath(self):
|
def config_filepath(self):
|
||||||
|
|
Loading…
Reference in a new issue