From 6f5de58d6e21a768f1a01159bf5e52aa9976b504 Mon Sep 17 00:00:00 2001 From: souliane Date: Sun, 8 Jun 2014 17:27:03 +0200 Subject: [PATCH] tools (config): fixConfigOption creates the section if it doesn't exist --- src/tools/config.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/tools/config.py b/src/tools/config.py index e1a17766..fbc3ff2a 100644 --- a/src/tools/config.py +++ b/src/tools/config.py @@ -26,7 +26,7 @@ log = getLogger(__name__) from sat.core.constants import Const as C from sat.core.i18n import _ -from ConfigParser import SafeConfigParser +from ConfigParser import SafeConfigParser, DEFAULTSECT from xdg import BaseDirectory import os @@ -54,6 +54,8 @@ def fixConfigOption(section, option, value, silent=True): if not target_file: # ... otherwise we create a new config file for that user target_file = BaseDirectory.save_config_path('sat') + '/sat.conf' + if section and section.upper() != DEFAULTSECT and not config.has_section(section): + config.add_section(section) config.set(section, option, value) with open(target_file, 'wb') as configfile: config.write(configfile) # for the next time that user launches sat