From 3fe4589b8bdde83e36f459d8f7be8776f46ab48e Mon Sep 17 00:00:00 2001 From: Davis Goglin Date: Wed, 30 Mar 2016 17:11:05 -0700 Subject: [PATCH] Add the reset of configurations between loads --- escpos/config.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/escpos/config.py b/escpos/config.py index bac19e0..a598393 100644 --- a/escpos/config.py +++ b/escpos/config.py @@ -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),