refactor(state): move state directory function into paths module
This commit is contained in:
@@ -6,7 +6,6 @@ from importlib import resources
|
||||
|
||||
APP_NAME = "rewind"
|
||||
CONFIG_NAME = "config.toml"
|
||||
STATE_NAME = "state.json"
|
||||
|
||||
def get_config_dir() -> Path:
|
||||
base = os.environ.get("XDG_CONFIG_HOME", Path.home() / ".config")
|
||||
@@ -25,4 +24,9 @@ def load_config() -> dict:
|
||||
|
||||
with config_file.open("rb") as f:
|
||||
return tomllib.load(f)
|
||||
|
||||
|
||||
def get_state_dir() -> Path:
|
||||
base = os.path.expanduser("~/.local/share")
|
||||
path = Path(base) / APP_NAME
|
||||
path.mkdir(parents=True, exist_ok=True)
|
||||
return path
|
||||
@@ -4,18 +4,12 @@ import json
|
||||
import os
|
||||
|
||||
from pathlib import Path
|
||||
from rewind.paths import get_state_dir
|
||||
|
||||
APP_NAME = "rewind"
|
||||
STATE_NAME = "state.json"
|
||||
|
||||
def state_dir() -> Path:
|
||||
base = os.path.expanduser("~/.local/share")
|
||||
path = Path(base) / APP_NAME
|
||||
path.mkdir(parents=True, exist_ok=True)
|
||||
return path
|
||||
|
||||
def get_state_file_path() -> Path:
|
||||
return state_dir() / STATE_NAME
|
||||
return get_state_dir() / STATE_NAME
|
||||
|
||||
def load_state() -> dict:
|
||||
if not get_state_file_path().exists():
|
||||
|
||||
Reference in New Issue
Block a user