From a602076291572826154abd8cb38c30c71f522f90 Mon Sep 17 00:00:00 2001 From: ldericher Date: Tue, 11 Aug 2020 17:23:24 +0200 Subject: [PATCH] clone default config before loading --- src/kiwi/config.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/kiwi/config.py b/src/kiwi/config.py index 7e467cf..22cf12d 100644 --- a/src/kiwi/config.py +++ b/src/kiwi/config.py @@ -1,3 +1,4 @@ +import copy import logging import re import os @@ -56,6 +57,12 @@ class Config: except yaml.YAMLError as exc: logging.error(exc) + def clone(self): + result = Config() + result.__yml_content = copy.deepcopy(self.__yml_content) + + return result + def save(self): with open(KIWI_CONF_NAME, 'w') as stream: stream.write(str(self)) @@ -79,7 +86,7 @@ class DefaultConfig(Config): class LoadedConfig(Config): @classmethod def get(cls): - result = DefaultConfig.get() + result = DefaultConfig.get().clone() if os.path.isfile(KIWI_CONF_NAME): result._update_from_file(KIWI_CONF_NAME)