Also try to load the root module for each path

This commit is contained in:
Ruud
2013-09-28 21:25:25 +02:00
parent 2f4f140662
commit 364e355114
6 changed files with 13 additions and 21 deletions
+2 -2
View File
@@ -1,4 +1,4 @@
config = { config = [{
'name': 'download_providers', 'name': 'download_providers',
'groups': [ 'groups': [
{ {
@@ -10,4 +10,4 @@ config = {
'options': [], 'options': [],
}, },
], ],
} }]
+3 -11
View File
@@ -1,6 +1,5 @@
from couchpotato.core.event import fireEvent from couchpotato.core.event import fireEvent
from couchpotato.core.logger import CPLog from couchpotato.core.logger import CPLog
import glob
import os import os
import traceback import traceback
@@ -81,17 +80,10 @@ class Loader(object):
def addFromDir(self, plugin_type, priority, module, dir_name): def addFromDir(self, plugin_type, priority, module, dir_name):
# Load dir module # Load dir module
try: self.addModule(priority, plugin_type, module, os.path.basename(dir_name))
m = __import__(module)
splitted = module.split('.')
for sub in splitted[1:]:
m = getattr(m, sub)
except:
raise
for cur_file in glob.glob(os.path.join(dir_name, '*')): for name in os.listdir(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(dir_name, name, '__init__.py')):
if os.path.isdir(os.path.join(dir_name, name)) and name != 'static' and os.path.isfile(os.path.join(cur_file, '__init__.py')):
module_name = '%s.%s' % (module, name) module_name = '%s.%s' % (module, name)
self.addModule(priority, plugin_type, module_name, name) self.addModule(priority, plugin_type, module_name, name)
+2 -2
View File
@@ -1,4 +1,4 @@
config = { config = [{
'name': 'notification_providers', 'name': 'notification_providers',
'groups': [ 'groups': [
{ {
@@ -10,4 +10,4 @@ config = {
'options': [], 'options': [],
}, },
], ],
} }]
@@ -1,4 +1,4 @@
config = { config = [{
'name': 'automation_providers', 'name': 'automation_providers',
'groups': [ 'groups': [
{ {
@@ -18,4 +18,4 @@ config = {
'options': [], 'options': [],
}, },
], ],
} }]
+2 -2
View File
@@ -1,4 +1,4 @@
config = { config = [{
'name': 'nzb_providers', 'name': 'nzb_providers',
'groups': [ 'groups': [
{ {
@@ -11,4 +11,4 @@ config = {
'options': [], 'options': [],
}, },
], ],
} }]
@@ -1,4 +1,4 @@
config = { config = [{
'name': 'torrent_providers', 'name': 'torrent_providers',
'groups': [ 'groups': [
{ {
@@ -11,4 +11,4 @@ config = {
'options': [], 'options': [],
}, },
], ],
} }]