diff --git a/my/cfg.py b/my/cfg.py index 3447525..2cd6454 100644 --- a/my/cfg.py +++ b/my/cfg.py @@ -27,3 +27,5 @@ def set_repo(name: str, repo: Union[Path, str]) -> None: # TODO set_repo is still useful, but perhaps move this thing away to core? + +# TODO ok, I need to get rid of this, better to rely on regular imports diff --git a/my/core/common.py b/my/core/common.py index 77ac086..1edf47b 100644 --- a/my/core/common.py +++ b/my/core/common.py @@ -34,9 +34,9 @@ def import_from(path: PathIsh, name: str) -> types.ModuleType: sys.path.remove(path) -def import_dir(path: PathIsh) -> types.ModuleType: +def import_dir(path: PathIsh, extra: str='') -> types.ModuleType: p = Path(path) - return import_from(p.parent, p.name) + return import_from(p.parent, p.name + extra) T = TypeVar('T') diff --git a/my/hypothesis.py b/my/hypothesis.py index 738ba6e..36d7e4f 100644 --- a/my/hypothesis.py +++ b/my/hypothesis.py @@ -26,11 +26,11 @@ class hypothesis(user_config): def dal_module(self): rpath = self.hypexport if rpath is not None: - from .cfg import set_repo - set_repo('hypexport', rpath) - - import my.config.repos.hypexport.dal as dal - return dal + from .core.common import import_dir + return import_dir(rpath, '.dal') + else: + import my.config.repos.hypexport.dal as dal + return dal from .core.cfg import make_config diff --git a/my/instapaper.py b/my/instapaper.py index 3ea064d..cb83031 100644 --- a/my/instapaper.py +++ b/my/instapaper.py @@ -25,11 +25,11 @@ class instapaper(user_config): def dal_module(self): rpath = self.instapexport if rpath is not None: - from .cfg import set_repo - set_repo('instapexport', rpath) - - import my.config.repos.instapexport.dal as dal - return dal + from .core.common import import_dir + return import_dir(rpath, '.dal') + else: + import my.config.repos.instapexport.dal as dal + return dal from .core.cfg import make_config diff --git a/my/reddit.py b/my/reddit.py index 7e9f908..04b1ca0 100755 --- a/my/reddit.py +++ b/my/reddit.py @@ -26,11 +26,11 @@ class reddit(uconfig): def dal_module(self) -> ModuleType: rpath = self.rexport if rpath is not None: - from .cfg import set_repo - set_repo('rexport', rpath) - - import my.config.repos.rexport.dal as dal - return dal + from .core.common import import_dir + return import_dir(rpath, '.dal') + else: + import my.config.repos.rexport.dal as dal + return dal from .core.cfg import make_config, Attrs