From 2de28153f0e7d4cb2a07e33a0567d608784b6fda Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Fri, 3 Nov 2017 02:32:32 +0100 Subject: [PATCH] The base class in e.g. plugins.music.mpd will be MusicMpdPlugin --- notifier.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/notifier.py b/notifier.py index 77c388bd0..67440ca4c 100644 --- a/notifier.py +++ b/notifier.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +import functools import importlib import os import logging @@ -57,7 +58,13 @@ def _exec_func(body): logging.info('Received push addressed to me: {}'.format(body)) args = body['args'] if 'args' in body else {} - cls = getattr(module, body['plugin'].title() + 'Plugin') + cls = getattr( + module, functools.reduce( + lambda a,b: a.title() + b.title(), + (body['plugin'].title().split('.')) + ) + 'Plugin' + ) + instance = cls() out, err = instance.run(args)