Skip to content

Commit 28ac3d2

Browse files
committed
Allow inheritance from disabled devices.
1 parent 25c192d commit 28ac3d2

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

myDevices/plugins/manager.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,18 @@ def load_plugin_from_file(self, filename):
3333
config = Config(filename)
3434
plugin_name = os.path.splitext(os.path.basename(filename))[0]
3535
info('Sections: {}'.format(config.sections()))
36+
inherited_from = set()
37+
for section in config.sections():
38+
inherit = config.get(section, 'inherit', None)
39+
if inherit:
40+
inherited_from.add(inherit)
3641
for section in config.sections():
3742
try:
3843
enabled = config.get(section, 'enabled', 'true').lower() == 'true'
3944
inherit = config.get(section, 'inherit', None)
40-
if enabled:
45+
if enabled or section in inherited_from:
4146
plugin = {
47+
'enabled': enabled,
4248
'filename': filename,
4349
'section': section,
4450
'channel': config.get(section, 'channel'),
@@ -94,6 +100,8 @@ def load_plugins(self):
94100
for root, dirnames, filenames in os.walk(self.plugin_folder):
95101
for filename in fnmatch.filter(filenames, '*.plugin'):
96102
self.load_plugin_from_file(os.path.join(root, filename))
103+
#Remove any disabled plugins that were only loaded because they are inherited from.
104+
self.plugins = {key:value for key, value in self.plugins.items() if value['enabled']}
97105

98106
def get_plugin(self, filename, section):
99107
"""Return the plugin for the corresponding filename and section."""

0 commit comments

Comments
 (0)