refactor(config): remove legacy ~/.config/mytoolkit compatibility
This commit is contained in:
+3
-8
@@ -7,7 +7,6 @@ from pathlib import Path
|
|||||||
_MYTOOLKIT_HOME = Path(os.environ.get("MYTOOLKIT_HOME", Path.home() / ".mytoolkit"))
|
_MYTOOLKIT_HOME = Path(os.environ.get("MYTOOLKIT_HOME", Path.home() / ".mytoolkit"))
|
||||||
CONFIG_PATH = _MYTOOLKIT_HOME / "env.json"
|
CONFIG_PATH = _MYTOOLKIT_HOME / "env.json"
|
||||||
_LEGACY_PATH = Path(__file__).parent / "config.json"
|
_LEGACY_PATH = Path(__file__).parent / "config.json"
|
||||||
_LEGACY_CONFIG_DIR = Path.home() / ".config" / "mytoolkit" / "env.json"
|
|
||||||
|
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
@@ -19,14 +18,10 @@ class Config:
|
|||||||
self._data = self._load()
|
self._data = self._load()
|
||||||
|
|
||||||
def _migrate_legacy(self) -> None:
|
def _migrate_legacy(self) -> None:
|
||||||
"""One-shot move of legacy configs into the user config dir."""
|
"""One-shot move of legacy bin/config.json into the user config dir."""
|
||||||
if self._config_path.exists():
|
if _LEGACY_PATH.exists() and not self._config_path.exists():
|
||||||
return
|
self._config_path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
self._config_path.parent.mkdir(parents=True, exist_ok=True)
|
|
||||||
if _LEGACY_PATH.exists():
|
|
||||||
_LEGACY_PATH.rename(self._config_path)
|
_LEGACY_PATH.rename(self._config_path)
|
||||||
elif _LEGACY_CONFIG_DIR.exists():
|
|
||||||
_LEGACY_CONFIG_DIR.rename(self._config_path)
|
|
||||||
|
|
||||||
def _load(self) -> dict:
|
def _load(self) -> dict:
|
||||||
if self._config_path.exists():
|
if self._config_path.exists():
|
||||||
|
|||||||
Reference in New Issue
Block a user