Add the reset of configurations between loads

This commit is contained in:
Davis Goglin 2016-03-30 17:11:05 -07:00
parent b9c9189ca7
commit 3fe4589b8b
1 changed files with 20 additions and 0 deletions

View File

@ -26,6 +26,23 @@ class Config(object):
_config_file = 'config.yaml'
def __init__(self):
""" Initialize configuration.
Remember to add anything that needs to be reset between configurations
to self._reset_config
"""
self._has_loaded = False
self._printer = None
self._printer_name = None
self._printer_config = None
def _reset_config(self):
""" Clear the loaded configuration.
If we are loading a changed config, we don't want to have leftover
data.
"""
self._has_loaded = False
self._printer = None
@ -39,6 +56,9 @@ class Config(object):
for the configuration file.
"""
self._reset_config()
if not config_path:
config_path = os.path.join(
appdirs.user_config_dir(self._app_name),