From edc91c227941f2de3047a06c51f9927e907ff7ff Mon Sep 17 00:00:00 2001 From: "Jip J. Dekker" Date: Sun, 8 Jun 2014 12:04:33 +0200 Subject: [PATCH] Sourceloader should import dynamically --- utils/sourceloader.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/sourceloader.py b/utils/sourceloader.py index 2ed50a8..b6bb0fd 100644 --- a/utils/sourceloader.py +++ b/utils/sourceloader.py @@ -8,7 +8,7 @@ from FourmiCrawler.sources.source import Source class SourceLoader: sources = [] - def __init__(self, rel_dir="FourmiCrawler/sources"): + def __init__(self, rel_dir="../FourmiCrawler/sources"): """ The initiation of a SourceLoader, selects and indexes a directory for usable sources. :param rel_dir: A relative path to a directory. @@ -18,7 +18,7 @@ class SourceLoader: known_parser = set() for py in [f[:-3] for f in os.listdir(path) if f.endswith('.py') and f != '__init__.py']: - mod = __import__('.'.join([rel_dir.replace("/", "."), py]), fromlist=[py]) + mod = __import__('.'.join([rel_dir.replace("../", "").replace("/", "."), py]), fromlist=[py]) classes = [getattr(mod, x) for x in dir(mod) if inspect.isclass(getattr(mod, x))] for cls in classes: if issubclass(cls, Source) and cls not in known_parser: