diff --git a/doc/MODULES.org b/doc/MODULES.org index d896eaa..07520f9 100644 --- a/doc/MODULES.org +++ b/doc/MODULES.org @@ -98,7 +98,7 @@ for cls, p in modules: export_path: Paths # path to a local clone of hypexport - # alternatively, you can put the repository (or a symlink) in $MY_CONFIG/repos/hypexport + # alternatively, you can put the repository (or a symlink) in $MY_CONFIG/my/config/repos/hypexport hypexport : Optional[PathIsh] = None #+end_src - [[file:../my/reddit.py][my.reddit]] @@ -115,7 +115,7 @@ for cls, p in modules: export_path: Paths # path to a local clone of rexport - # alternatively, you can put the repository (or a symlink) in $MY_CONFIG/repos/rexport + # alternatively, you can put the repository (or a symlink) in $MY_CONFIG/my/config/repos/rexport rexport : Optional[PathIsh] = None #+end_src - [[file:../my/twitter/twint.py][my.twitter.twint]] @@ -172,7 +172,7 @@ for cls, p in modules: export_path : Paths # path to a local clone of instapexport - # alternatively, you can put the repository (or a symlink) in $MY_CONFIG/repos/instapexport + # alternatively, you can put the repository (or a symlink) in $MY_CONFIG/my/config/repos/instapexport instapexport: Optional[PathIsh] = None #+end_src :end: diff --git a/my/core/common.py b/my/core/common.py index 1edf47b..dec0b15 100644 --- a/my/core/common.py +++ b/my/core/common.py @@ -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) diff --git a/tests/get_files.py b/tests/get_files.py index a3fd5a9..29e0528 100644 --- a/tests/get_files.py +++ b/tests/get_files.py @@ -26,6 +26,12 @@ def test_single_file(): ) + "if the path starts with ~, we expand it" + assert get_files('~/.bashrc') == ( + Path('~').expanduser() / '.bashrc', + ) + + def test_multiple_files(): ''' If you pass a directory/multiple directories, it flattens the contents