|
|
@ -221,13 +221,10 @@ class ConfigReaderUnshared(SafeConfigParserWithIncludes):
|
|
|
|
# Or it is a dict:
|
|
|
|
# Or it is a dict:
|
|
|
|
# {name: [type, default], ...}
|
|
|
|
# {name: [type, default], ...}
|
|
|
|
|
|
|
|
|
|
|
|
def getOptions(self, sec, options, pOptions=None,
|
|
|
|
def getOptions(self, sec, options, pOptions=None, shouldExist=False):
|
|
|
|
allOpts=None, shouldExist=False
|
|
|
|
|
|
|
|
):
|
|
|
|
|
|
|
|
values = dict()
|
|
|
|
values = dict()
|
|
|
|
if pOptions is None:
|
|
|
|
if pOptions is None:
|
|
|
|
pOptions = {}
|
|
|
|
pOptions = {}
|
|
|
|
|
|
|
|
|
|
|
|
# Get only specified options:
|
|
|
|
# Get only specified options:
|
|
|
|
for optname in options:
|
|
|
|
for optname in options:
|
|
|
|
if isinstance(options, (list,tuple)):
|
|
|
|
if isinstance(options, (list,tuple)):
|
|
|
@ -265,15 +262,6 @@ class ConfigReaderUnshared(SafeConfigParserWithIncludes):
|
|
|
|
logSys.warning("Wrong value for '" + optname + "' in '" + sec +
|
|
|
|
logSys.warning("Wrong value for '" + optname + "' in '" + sec +
|
|
|
|
"'. Using default one: '" + repr(optvalue) + "'")
|
|
|
|
"'. Using default one: '" + repr(optvalue) + "'")
|
|
|
|
values[optname] = optvalue
|
|
|
|
values[optname] = optvalue
|
|
|
|
|
|
|
|
|
|
|
|
# Fill all option of the section (used for replacement):
|
|
|
|
|
|
|
|
if allOpts is not None and self.has_section(sec):
|
|
|
|
|
|
|
|
for optname in self.options(sec):
|
|
|
|
|
|
|
|
v = values.get(optname)
|
|
|
|
|
|
|
|
if v is None:
|
|
|
|
|
|
|
|
v = self.get(sec, optname, vars=pOptions)
|
|
|
|
|
|
|
|
allOpts[optname] = v
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return values
|
|
|
|
return values
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -293,6 +281,8 @@ class DefinitionInitConfigReader(ConfigReader):
|
|
|
|
self.setFile(file_)
|
|
|
|
self.setFile(file_)
|
|
|
|
self.setJailName(jailName)
|
|
|
|
self.setJailName(jailName)
|
|
|
|
self._initOpts = initOpts
|
|
|
|
self._initOpts = initOpts
|
|
|
|
|
|
|
|
self._pOpts = dict()
|
|
|
|
|
|
|
|
self._defCache = dict()
|
|
|
|
|
|
|
|
|
|
|
|
def setFile(self, fileName):
|
|
|
|
def setFile(self, fileName):
|
|
|
|
self._file = fileName
|
|
|
|
self._file = fileName
|
|
|
@ -323,9 +313,9 @@ class DefinitionInitConfigReader(ConfigReader):
|
|
|
|
if not pOpts:
|
|
|
|
if not pOpts:
|
|
|
|
pOpts = dict()
|
|
|
|
pOpts = dict()
|
|
|
|
pOpts = _merge_dicts(pOpts, self._initOpts)
|
|
|
|
pOpts = _merge_dicts(pOpts, self._initOpts)
|
|
|
|
self._allOpts = dict()
|
|
|
|
|
|
|
|
self._opts = ConfigReader.getOptions(
|
|
|
|
self._opts = ConfigReader.getOptions(
|
|
|
|
self, "Definition", self._configOpts, pOpts, allOpts=self._allOpts)
|
|
|
|
self, "Definition", self._configOpts, pOpts)
|
|
|
|
|
|
|
|
self._pOpts = pOpts
|
|
|
|
if self.has_section("Init"):
|
|
|
|
if self.has_section("Init"):
|
|
|
|
for opt in self.options("Init"):
|
|
|
|
for opt in self.options("Init"):
|
|
|
|
v = self.get("Init", opt)
|
|
|
|
v = self.get("Init", opt)
|
|
|
@ -337,6 +327,17 @@ class DefinitionInitConfigReader(ConfigReader):
|
|
|
|
def _convert_to_boolean(self, value):
|
|
|
|
def _convert_to_boolean(self, value):
|
|
|
|
return value.lower() in ("1", "yes", "true", "on")
|
|
|
|
return value.lower() in ("1", "yes", "true", "on")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def getCombOption(self, optname):
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
return self._defCache[optname]
|
|
|
|
|
|
|
|
except KeyError:
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
v = self.get("Definition", optname, vars=self._pOpts)
|
|
|
|
|
|
|
|
except (NoSectionError, NoOptionError, ValueError):
|
|
|
|
|
|
|
|
v = None
|
|
|
|
|
|
|
|
self._defCache[optname] = v
|
|
|
|
|
|
|
|
return v
|
|
|
|
|
|
|
|
|
|
|
|
def getCombined(self, ignore=()):
|
|
|
|
def getCombined(self, ignore=()):
|
|
|
|
combinedopts = self._opts
|
|
|
|
combinedopts = self._opts
|
|
|
|
ignore = set(ignore).copy()
|
|
|
|
ignore = set(ignore).copy()
|
|
|
@ -352,7 +353,7 @@ class DefinitionInitConfigReader(ConfigReader):
|
|
|
|
ignore.add(n)
|
|
|
|
ignore.add(n)
|
|
|
|
# substiture options already specified direct:
|
|
|
|
# substiture options already specified direct:
|
|
|
|
opts = CommandAction.substituteRecursiveTags(combinedopts,
|
|
|
|
opts = CommandAction.substituteRecursiveTags(combinedopts,
|
|
|
|
ignore=ignore, addtags=self._allOpts)
|
|
|
|
ignore=ignore, addrepl=self.getCombOption)
|
|
|
|
if not opts:
|
|
|
|
if not opts:
|
|
|
|
raise ValueError('recursive tag definitions unable to be resolved')
|
|
|
|
raise ValueError('recursive tag definitions unable to be resolved')
|
|
|
|
return opts
|
|
|
|
return opts
|
|
|
|