From 364e355114bdc429fde88c7d5c812df7fdab96ad Mon Sep 17 00:00:00 2001 From: Ruud Date: Sat, 28 Sep 2013 21:25:25 +0200 Subject: [PATCH] Also try to load the root module for each path --- couchpotato/core/downloaders/__init__.py | 4 ++-- couchpotato/core/loader.py | 14 +++----------- couchpotato/core/notifications/__init__.py | 4 ++-- couchpotato/core/providers/automation/__init__.py | 4 ++-- couchpotato/core/providers/nzb/__init__.py | 4 ++-- couchpotato/core/providers/torrent/__init__.py | 4 ++-- 6 files changed, 13 insertions(+), 21 deletions(-) diff --git a/couchpotato/core/downloaders/__init__.py b/couchpotato/core/downloaders/__init__.py index 5fb7125f..a81ce881 100644 --- a/couchpotato/core/downloaders/__init__.py +++ b/couchpotato/core/downloaders/__init__.py @@ -1,4 +1,4 @@ -config = { +config = [{ 'name': 'download_providers', 'groups': [ { @@ -10,4 +10,4 @@ config = { 'options': [], }, ], -} +}] diff --git a/couchpotato/core/loader.py b/couchpotato/core/loader.py index 2016d287..9362bb8c 100644 --- a/couchpotato/core/loader.py +++ b/couchpotato/core/loader.py @@ -1,6 +1,5 @@ from couchpotato.core.event import fireEvent from couchpotato.core.logger import CPLog -import glob import os import traceback @@ -81,17 +80,10 @@ class Loader(object): def addFromDir(self, plugin_type, priority, module, dir_name): # Load dir module - try: - m = __import__(module) - splitted = module.split('.') - for sub in splitted[1:]: - m = getattr(m, sub) - except: - raise + self.addModule(priority, plugin_type, module, os.path.basename(dir_name)) - for cur_file in glob.glob(os.path.join(dir_name, '*')): - name = os.path.basename(cur_file) - if os.path.isdir(os.path.join(dir_name, name)) and name != 'static' and os.path.isfile(os.path.join(cur_file, '__init__.py')): + for name in os.listdir(dir_name): + if os.path.isdir(os.path.join(dir_name, name)) and name != 'static' and os.path.isfile(os.path.join(dir_name, name, '__init__.py')): module_name = '%s.%s' % (module, name) self.addModule(priority, plugin_type, module_name, name) diff --git a/couchpotato/core/notifications/__init__.py b/couchpotato/core/notifications/__init__.py index 8ac24dfb..5958fe66 100644 --- a/couchpotato/core/notifications/__init__.py +++ b/couchpotato/core/notifications/__init__.py @@ -1,4 +1,4 @@ -config = { +config = [{ 'name': 'notification_providers', 'groups': [ { @@ -10,4 +10,4 @@ config = { 'options': [], }, ], -} +}] diff --git a/couchpotato/core/providers/automation/__init__.py b/couchpotato/core/providers/automation/__init__.py index a217948a..93f6c10a 100644 --- a/couchpotato/core/providers/automation/__init__.py +++ b/couchpotato/core/providers/automation/__init__.py @@ -1,4 +1,4 @@ -config = { +config = [{ 'name': 'automation_providers', 'groups': [ { @@ -18,4 +18,4 @@ config = { 'options': [], }, ], -} +}] diff --git a/couchpotato/core/providers/nzb/__init__.py b/couchpotato/core/providers/nzb/__init__.py index 36098bb3..88d9865d 100644 --- a/couchpotato/core/providers/nzb/__init__.py +++ b/couchpotato/core/providers/nzb/__init__.py @@ -1,4 +1,4 @@ -config = { +config = [{ 'name': 'nzb_providers', 'groups': [ { @@ -11,4 +11,4 @@ config = { 'options': [], }, ], -} +}] diff --git a/couchpotato/core/providers/torrent/__init__.py b/couchpotato/core/providers/torrent/__init__.py index 250bcead..12dda708 100644 --- a/couchpotato/core/providers/torrent/__init__.py +++ b/couchpotato/core/providers/torrent/__init__.py @@ -1,4 +1,4 @@ -config = { +config = [{ 'name': 'torrent_providers', 'groups': [ { @@ -11,4 +11,4 @@ config = { 'options': [], }, ], -} +}]