# HG changeset patch # User souliane # Date 1402241223 -7200 # Node ID a5cfa9bb4541ae86fc3a542e1932d14e696df5bd # Parent abcac1ac27a79cc6fb4b1f86cf193d12c043ce94 tools (config): fixConfigOption creates the section if it doesn't exist diff -r abcac1ac27a7 -r a5cfa9bb4541 src/tools/config.py --- a/src/tools/config.py Sat Jun 07 16:39:08 2014 +0200 +++ b/src/tools/config.py Sun Jun 08 17:27:03 2014 +0200 @@ -26,7 +26,7 @@ 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 @@ 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