[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:
Tobias Witek 2019-11-30 13:52:27 +01:00
parent 24442e88e8
commit 9d7fdfa1a3

View file

@ -118,8 +118,10 @@ class Module(object):
def parameter(self, name, default=None):
"""Return the config parameter 'name' for this module"""
module_name = "{}.{}".format(self.__module__.split(".")[-1], 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:
try:
value = self._configFile.get("module-parameters", name)