From b082fbc0a5e5c6c3b1eebb5b34a002385b3653e4 Mon Sep 17 00:00:00 2001 From: Jesse Mullan Date: Sun, 26 Oct 2014 09:09:12 -0700 Subject: [PATCH] Make sure that old config data is all written out --- headphones/config.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/headphones/config.py b/headphones/config.py index 3ad66bae..2023e7a1 100644 --- a/headphones/config.py +++ b/headphones/config.py @@ -276,6 +276,15 @@ class Config(object): new_config = ConfigObj(encoding="UTF-8") new_config.filename = self._config_file + # first copy over everything from the old config, even if it is not correctly + # defined to keep from losing data + for key, subkeys in self._config.items(): + if key not in new_config: + new_config[key] = {} + for subkey, value in subkeys.items(): + new_config[key][subkey] = value + + # next make sure that everything we expect to have defined is so for key in _config_definitions.keys(): key, definition_type, section, ini_key, default = self._define(key) self.check_setting(key)