Browse Source

22/04/2016

prieto 9 years ago
parent
commit
0c65414dda
2 changed files with 8 additions and 7 deletions
  1. 6
    6
      lodel/settings/settings.py
  2. 2
    1
      lodel/settings/settings_loader.py

+ 6
- 6
lodel/settings/settings.py View File

@@ -113,16 +113,16 @@ class Settings(object, metaclass=MetaSettings):
113 113
                 raise RuntimeError("The Settings class is not started yet")
114 114
         else:
115 115
             if cls.started():
116
-                raise RuntimeError("The Settings class is allready started")
116
+                raise RuntimeError("The Settings class is already started")
117 117
 
118
-    ##@brief Saves a new configutration for section confname
118
+    ##@brief Saves a new configuration for section confname
119 119
     #@param confname is the name of the modified section
120 120
     #@param confvalue is a dict with variables to save
121 121
     #@param validators is a dict with adapted validator
122 122
     @classmethod
123
-    def set(cls, confname, confvalue,validators,loader):
124
-        for key in confvalue:
125
-            loader.setoption(confname, key, confvalue[key], validators[key])
123
+    def set(cls, confname, confvalue,validator, loader):
124
+        confkey=confname.rpartition('.')
125
+        loader.setoption(confkey[0], confkey[2], confvalue, validator)
126 126
 
127 127
     ##@brief This method handlers Settings instance bootstraping
128 128
     def __bootstrap(self):
@@ -268,7 +268,7 @@ class Settings(object, metaclass=MetaSettings):
268 268
             else:
269 269
                 curname, cur = left[0]
270 270
                 path.append( (curname, cur) )
271
-                nodename += '.'+curname.title()
271
+                nodename += '.' + curname.title()
272 272
     
273 273
     ##@brief Forge a named tuple given a conftree node
274 274
     # @param conftree dict : A conftree node

+ 2
- 1
lodel/settings/settings_loader.py View File

@@ -93,7 +93,8 @@ class SettingsLoader(object):
93 93
         conf[section][keyname] = value
94 94
         config = configparser.ConfigParser()
95 95
         config.read(f_conf)
96
-        config[section]={}
96
+        if section not in config:
97
+            config[section]={}
97 98
         config[section][keyname] = validator(value)
98 99
         
99 100
         with open(f_conf, 'w') as configfile:

Loading…
Cancel
Save