[core] Allow fallback of config parameters
Some modules (such as pulseaudio) have aliases (pasink, pasource), which mean that the module's name might differ from it's "parent" name. To make it possible to have shared config parameters, add a fallback that reads the "module" parameter, if no instance parameter is found. fixes #467
This commit is contained in:
parent
24442e88e8
commit
9d7fdfa1a3
1 changed files with 3 additions and 1 deletions
|
@ -118,8 +118,10 @@ class Module(object):
|
||||||
|
|
||||||
def parameter(self, name, default=None):
|
def parameter(self, name, default=None):
|
||||||
"""Return the config parameter 'name' for this module"""
|
"""Return the config parameter 'name' for this module"""
|
||||||
|
module_name = "{}.{}".format(self.__module__.split(".")[-1], name)
|
||||||
name = "{}.{}".format(self.name, name)
|
name = "{}.{}".format(self.name, name)
|
||||||
value = self._config["config"].get(name, default)
|
value = self._config["config"].get(module_name, default)
|
||||||
|
value = self._config["config"].get(name, value)
|
||||||
if value == default:
|
if value == default:
|
||||||
try:
|
try:
|
||||||
value = self._configFile.get("module-parameters", name)
|
value = self._configFile.get("module-parameters", name)
|
||||||
|
|
Loading…
Reference in a new issue