clone default config before loading

This commit is contained in:
Jörn-Michael Miehe 2020-08-11 17:23:24 +02:00
parent 9da09d56cf
commit a602076291

View file

@ -1,3 +1,4 @@
import copy
import logging import logging
import re import re
import os import os
@ -56,6 +57,12 @@ class Config:
except yaml.YAMLError as exc: except yaml.YAMLError as exc:
logging.error(exc) logging.error(exc)
def clone(self):
result = Config()
result.__yml_content = copy.deepcopy(self.__yml_content)
return result
def save(self): def save(self):
with open(KIWI_CONF_NAME, 'w') as stream: with open(KIWI_CONF_NAME, 'w') as stream:
stream.write(str(self)) stream.write(str(self))
@ -79,7 +86,7 @@ class DefaultConfig(Config):
class LoadedConfig(Config): class LoadedConfig(Config):
@classmethod @classmethod
def get(cls): def get(cls):
result = DefaultConfig.get() result = DefaultConfig.get().clone()
if os.path.isfile(KIWI_CONF_NAME): if os.path.isfile(KIWI_CONF_NAME):
result._update_from_file(KIWI_CONF_NAME) result._update_from_file(KIWI_CONF_NAME)