From 856e4fe2e14f71e5814f2bc51d15f64c312695f7 Mon Sep 17 00:00:00 2001 From: Ryan Reed Date: Sat, 16 Jul 2022 23:34:20 -0400 Subject: [PATCH] Expanding and replacing home for more portability --- pyproject.toml | 2 +- src/transpose/transpose.py | 4 ++-- src/transpose/utils.py | 6 +++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 7b66965..8303a8e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "transpose" -version = "1.0.0" +version = "1.0.1" description = "Move and symlink a path" authors = ["Ryan Reed"] license = "GPLv3" diff --git a/src/transpose/transpose.py b/src/transpose/transpose.py index 4a207e7..e24d7f7 100644 --- a/src/transpose/transpose.py +++ b/src/transpose/transpose.py @@ -29,7 +29,7 @@ class Transpose: ) cache = get_cache(self.cache_path) - original_path = pathlib.Path(cache["original_path"]) + original_path = pathlib.Path(cache["original_path"]).expanduser() if original_path.is_symlink(): remove(original_path) @@ -67,7 +67,7 @@ class Transpose: raise TransposeError(f"Target path does not exist: {self.target_path}") cache = get_cache(self.cache_path) - original_path = pathlib.Path(cache["original_path"]) + original_path = pathlib.Path(cache["original_path"]).expanduser() if original_path.is_symlink(): remove(original_path) diff --git a/src/transpose/utils.py b/src/transpose/utils.py index 35b95d3..ef7735a 100644 --- a/src/transpose/utils.py +++ b/src/transpose/utils.py @@ -41,7 +41,11 @@ def create_cache(cache_path: Path, original_path: Path) -> None: Returns: None """ - template = {"version": version, "original_path": str(original_path.absolute())} + template = { + "version": version, + "original_path": str(original_path.absolute()).replace(str(Path.home()), "~"), + } + with open(str(cache_path), "w") as f: json.dump(template, f)