core/modules: get rid of set_repo uses, it was just complicating everythin

This commit is contained in:
Dima Gerasimov 2020-05-18 21:33:52 +01:00
parent 0f80e9d5e6
commit 403ec18385
5 changed files with 19 additions and 17 deletions

View file

@ -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 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

View file

@ -34,9 +34,9 @@ def import_from(path: PathIsh, name: str) -> types.ModuleType:
sys.path.remove(path) sys.path.remove(path)
def import_dir(path: PathIsh) -> types.ModuleType: def import_dir(path: PathIsh, extra: str='') -> types.ModuleType:
p = Path(path) p = Path(path)
return import_from(p.parent, p.name) return import_from(p.parent, p.name + extra)
T = TypeVar('T') T = TypeVar('T')

View file

@ -26,11 +26,11 @@ class hypothesis(user_config):
def dal_module(self): def dal_module(self):
rpath = self.hypexport rpath = self.hypexport
if rpath is not None: if rpath is not None:
from .cfg import set_repo from .core.common import import_dir
set_repo('hypexport', rpath) return import_dir(rpath, '.dal')
else:
import my.config.repos.hypexport.dal as dal import my.config.repos.hypexport.dal as dal
return dal return dal
from .core.cfg import make_config from .core.cfg import make_config

View file

@ -25,11 +25,11 @@ class instapaper(user_config):
def dal_module(self): def dal_module(self):
rpath = self.instapexport rpath = self.instapexport
if rpath is not None: if rpath is not None:
from .cfg import set_repo from .core.common import import_dir
set_repo('instapexport', rpath) return import_dir(rpath, '.dal')
else:
import my.config.repos.instapexport.dal as dal import my.config.repos.instapexport.dal as dal
return dal return dal
from .core.cfg import make_config from .core.cfg import make_config

View file

@ -26,11 +26,11 @@ class reddit(uconfig):
def dal_module(self) -> ModuleType: def dal_module(self) -> ModuleType:
rpath = self.rexport rpath = self.rexport
if rpath is not None: if rpath is not None:
from .cfg import set_repo from .core.common import import_dir
set_repo('rexport', rpath) return import_dir(rpath, '.dal')
else:
import my.config.repos.rexport.dal as dal import my.config.repos.rexport.dal as dal
return dal return dal
from .core.cfg import make_config, Attrs from .core.cfg import make_config, Attrs