diff --git a/src/transpose/__init__.py b/src/transpose/__init__.py index 8982260..c8d96b7 100644 --- a/src/transpose/__init__.py +++ b/src/transpose/__init__.py @@ -1,6 +1,7 @@ -from importlib.metadata import version import os +from importlib.metadata import version + from .logger import create_logger DEFAULT_XDG_PATH = os.environ.get("XDG_DATA_HOME", f"{os.environ['HOME']}/.local/share") diff --git a/src/transpose/transpose.py b/src/transpose/transpose.py index 36879cd..7835c27 100644 --- a/src/transpose/transpose.py +++ b/src/transpose/transpose.py @@ -1,4 +1,4 @@ -from pathlib import Path +import pathlib from .exceptions import TransposeError from .utils import check_path, create_cache, get_cache, move, remove, symlink @@ -11,13 +11,13 @@ class Transpose: store_path: str, cache_filename: str = None, ) -> None: - self.target_path = Path(target_path) - self.store_path = Path(store_path) + self.target_path = pathlib.Path(target_path) + self.store_path = pathlib.Path(store_path) if not cache_filename: cache_filename = ".transpose.json" self.cache_filename = cache_filename - self.cache_path = Path(self.target_path).joinpath(cache_filename) + self.cache_path = pathlib.Path(self.target_path).joinpath(cache_filename) def apply(self) -> None: """ @@ -29,7 +29,7 @@ class Transpose: ) cache = get_cache(self.cache_path) - original_path = Path(cache["original_path"]) + original_path = pathlib.Path(cache["original_path"]) if original_path.is_symlink(): remove(original_path) @@ -48,7 +48,7 @@ class Transpose: raise TransposeError(f"Target path does not exist: {self.target_path}") cache = get_cache(self.cache_path) - original_path = Path(cache["original_path"]) + original_path = pathlib.Path(cache["original_path"]) if original_path.is_symlink(): remove(original_path) @@ -64,14 +64,14 @@ class Transpose: f"Original path, {original_path}, does not exist. Use '-f' to create the path" ) - new_cache_path = Path(original_path).joinpath(self.cache_filename) + new_cache_path = pathlib.Path(original_path).joinpath(self.cache_filename) remove(new_cache_path) def store(self, name: str) -> None: """ Moves a directory to a central location and creates a symlink to the old path. """ - new_location = Path(self.store_path).joinpath(name) + new_location = pathlib.Path(self.store_path).joinpath(name) if not check_path(path=self.target_path): raise TransposeError( diff --git a/src/transpose/utils.py b/src/transpose/utils.py index 9c3e31d..fbe7c53 100644 --- a/src/transpose/utils.py +++ b/src/transpose/utils.py @@ -1,9 +1,9 @@ -from pathlib import Path -from typing import Dict - import json import shutil +from pathlib import Path +from typing import Dict + from . import version diff --git a/tests/test_transpose.py b/tests/test_transpose.py index 1f45274..907d514 100644 --- a/tests/test_transpose.py +++ b/tests/test_transpose.py @@ -1,8 +1,7 @@ import json +import pathlib import pytest -from pathlib import Path - from transpose import Transpose, version, DEFAULT_CACHE_FILENAME from transpose.exceptions import TransposeError @@ -16,19 +15,19 @@ def test_init(): store_path=STORE_DIR, ) assert t.cache_filename == ".transpose.json" - assert t.cache_path == Path(TARGET_DIR).joinpath(".transpose.json") + assert t.cache_path == pathlib.Path(TARGET_DIR).joinpath(".transpose.json") t = Transpose( target_path=TARGET_DIR, store_path=STORE_DIR, cache_filename=".transpose.txt" ) assert t.cache_filename == ".transpose.txt" - assert t.cache_path == Path(TARGET_DIR).joinpath(".transpose.txt") + assert t.cache_path == pathlib.Path(TARGET_DIR).joinpath(".transpose.txt") @setup_env() def test_apply(): - store_path = Path(STORE_DIR) - target_path = Path(TARGET_DIR) + store_path = pathlib.Path(STORE_DIR) + target_path = pathlib.Path(TARGET_DIR) store_path.rmdir() target_path.rename(store_path) @@ -50,8 +49,8 @@ def test_store_restore(): ) t.store("TestStore") - target_path = Path(TARGET_DIR) - store_path = Path(STORE_DIR).joinpath("TestStore") + target_path = pathlib.Path(TARGET_DIR) + store_path = pathlib.Path(STORE_DIR).joinpath("TestStore") assert store_path.is_dir() and not store_path.is_symlink() assert target_path.is_dir() and target_path.is_symlink()