|
@@ -31,6 +31,7 @@ from lodel.settings.settings_loader import SettingsLoader
|
31
|
31
|
# - value validation/cast (see @ref Lodel.settings.validator.ConfValidator )
|
32
|
32
|
#
|
33
|
33
|
|
|
34
|
+## @brief A default python system lib path
|
34
|
35
|
PYTHON_SYS_LIB_PATH = '/usr/local/lib/python{major}.{minor}/'.format(
|
35
|
36
|
|
36
|
37
|
major = sys.version_info.major,
|
|
@@ -73,7 +74,9 @@ class Settings(object):
|
73
|
74
|
'plugins_path': ( PYTHON_SYS_LIB_PATH+'lodel2/plugins/',
|
74
|
75
|
SettingValidator('directory_list')),
|
75
|
76
|
}
|
|
77
|
+ instance = None
|
76
|
78
|
|
|
79
|
+ ## @brief Should be called only by the boostrap classmethod
|
77
|
80
|
def __init__(self, conf_file = '/etc/lodel2/lodel2.conf', conf_dir = 'conf.d'):
|
78
|
81
|
self.__confs = dict()
|
79
|
82
|
self.__conf_dir = conf_dir
|
|
@@ -82,6 +85,13 @@ class Settings(object):
|
82
|
85
|
# and self.__confs['lodel2']['lib_path'] set
|
83
|
86
|
self.__bootstrap()
|
84
|
87
|
|
|
88
|
+ ## @brief Stores as class attribute a Settings instance
|
|
89
|
+ @classmethod
|
|
90
|
+ def bootstrap(cls, conf_file = None, conf_dir = None):
|
|
91
|
+ if cls.instance is None:
|
|
92
|
+ cls.instance = cls(conf_file, conf_dir)
|
|
93
|
+ return cls.instance
|
|
94
|
+
|
85
|
95
|
## @brief Configuration keys accessor
|
86
|
96
|
# @return All confs organised into named tuples
|
87
|
97
|
@property
|
|
@@ -140,12 +150,9 @@ class Settings(object):
|
140
|
150
|
# Construct final specs dict replacing variable sections
|
141
|
151
|
# by the actual existing sections
|
142
|
152
|
variable_sections = [ section for section in specs if section.endswith('.*') ]
|
143
|
|
- print("DEBUG VARIABLE SECTIONS : ")
|
144
|
153
|
for vsec in variable_sections:
|
145
|
154
|
preffix = vsec[:-2]
|
146
|
|
- print("PREFFIX = ", preffix)
|
147
|
155
|
for section in loader.getsection(preffix, 'default'): #WARNING : hardcoded default section
|
148
|
|
- print("SECTIONs = ", section)
|
149
|
156
|
specs[section] = copy.copy(specs[vsec])
|
150
|
157
|
del(specs[vsec])
|
151
|
158
|
# Fetching valuds for sections
|