Browse Source

Modifying settings class to allow usage of custom confspecs

a bit dirty & quick
Yann Weber 8 years ago
parent
commit
0ffe60ff2b
1 changed files with 9 additions and 3 deletions
  1. 9
    3
      lodel/settings/settings.py

+ 9
- 3
lodel/settings/settings.py View File

80
     
80
     
81
     ## @brief Instanciate the Settings singleton
81
     ## @brief Instanciate the Settings singleton
82
     # @param conf_dir str : The configuration directory
82
     # @param conf_dir str : The configuration directory
83
-    def __init__(self, conf_dir):
83
+    #@param custom_confspec None | dict : if given overwrite default lodel2
84
+    #confspecs
85
+    def __init__(self, conf_dir, custom_confspecs = None):
84
         self.singleton_assert() # check that it is the only instance
86
         self.singleton_assert() # check that it is the only instance
85
         Settings.instance = self
87
         Settings.instance = self
86
         ## @brief Configuration specification
88
         ## @brief Configuration specification
87
         #
89
         #
88
         # Initialized by Settings.__bootstrap() method
90
         # Initialized by Settings.__bootstrap() method
89
-        self.__conf_specs = None
91
+        self.__conf_specs = custom_confspecs
90
         ## @brief Stores the configurations in namedtuple tree
92
         ## @brief Stores the configurations in namedtuple tree
91
         self.__confs = None
93
         self.__confs = None
92
         self.__conf_dir = conf_dir
94
         self.__conf_dir = conf_dir
137
         LodelContext.expose_modules(globals(), {
139
         LodelContext.expose_modules(globals(), {
138
             'lodel.plugin.plugins': ['Plugin', 'PluginError']})
140
             'lodel.plugin.plugins': ['Plugin', 'PluginError']})
139
         logger.debug("Settings bootstraping")
141
         logger.debug("Settings bootstraping")
140
-        lodel2_specs = LODEL2_CONF_SPECS
142
+        if self.__conf_specs is None:
143
+            lodel2_specs = LODEL2_CONF_SPECS
144
+        else:
145
+            lodel2_specs = self.__conf_specs
146
+            self.__conf_specs = None
141
         loader = SettingsLoader(self.__conf_dir) 
147
         loader = SettingsLoader(self.__conf_dir) 
142
         plugin_list = []
148
         plugin_list = []
143
         for ptype_name,ptype in Plugin.plugin_types().items():
149
         for ptype_name,ptype in Plugin.plugin_types().items():

Loading…
Cancel
Save