core: expand '~' in get_files & import_dir

This commit is contained in:
Dima Gerasimov 2020-05-18 21:50:36 +01:00
parent 403ec18385
commit c8bdbfd69f
3 changed files with 13 additions and 3 deletions

View file

@ -36,6 +36,8 @@ def import_from(path: PathIsh, name: str) -> types.ModuleType:
def import_dir(path: PathIsh, extra: str='') -> types.ModuleType:
p = Path(path)
if p.parts[0] == '~':
p = p.expanduser() # TODO eh. not sure about this..
return import_from(p.parent, p.name + extra)
@ -130,6 +132,8 @@ def get_files(pp: Paths, glob: str=DEFAULT_GLOB, sort: bool=True) -> Tuple[Path,
paths: List[Path] = []
for src in sources:
if src.parts[0] == '~':
src = src.expanduser()
if src.is_dir():
gp: Iterable[Path] = src.glob(glob)
paths.extend(gp)