From 45ac81e232b843051b0790fe1469dfb5abb50bda Mon Sep 17 00:00:00 2001 From: schneefux Date: Tue, 30 Sep 2014 18:50:16 +0200 Subject: Stop using hardcoded 'modules' prefix in brain.py This makes the modules path truly configurable --- client/brain.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'client') diff --git a/client/brain.py b/client/brain.py index 007b7fe..6daa366 100644 --- a/client/brain.py +++ b/client/brain.py @@ -35,11 +35,11 @@ class Brain(object): logger = logging.getLogger(__name__) module_locations = [jasperpath.PLUGIN_PATH] logger.debug("Looking for modules in: %s", ', '.join(["'%s'" % location for location in module_locations])) - module_names = [name for loader, name, ispkg in pkgutil.walk_packages(module_locations, prefix='modules.')] modules = [] - for name in module_names: + for finder, name, ispkg in pkgutil.walk_packages(module_locations): try: - mod = importlib.import_module(name) + loader = finder.find_module(name) + mod = loader.load_module(name) except: logger.warning("Skipped module '%s' due to an error.", name, exc_info=True) else: -- cgit v1.3.1 From be97529c4c5462aca3b01d69a91f62fd1cd5748a Mon Sep 17 00:00:00 2001 From: schneefux Date: Tue, 30 Sep 2014 19:25:22 +0200 Subject: Update Brain testcase --- client/test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'client') diff --git a/client/test.py b/client/test.py index 9c99688..23dd619 100644 --- a/client/test.py +++ b/client/test.py @@ -224,7 +224,7 @@ class TestBrain(unittest.TestCase): def testPriority(self): """Does Brain correctly send query to higher-priority module?""" my_brain = TestBrain._emptyBrain() - hn_module = 'modules.HN' + hn_module = 'HN' hn = filter(lambda m: m.__name__ == hn_module, my_brain.modules)[0] with patch.object(hn, 'handle') as mocked_handle: -- cgit v1.3.1