Move scraped book details into data folder

This commit is contained in:
SirBlob committed 2026-11-01 22:58:56 -05:00
1 parent 9ce67f7600
commit 1f7e88f117
9 files changed
+190 -252

No files matched your search

+26 -4
View File
@@ -3,6 +3,7 @@ from pathlib import Path
PROJECT_ROOT = Path(__file__).resolve().parents[2]
CONTENT_DIR = PROJECT_ROOT / "content"
DATA_DIR = PROJECT_ROOT / "data"
INLINE_LIST_MAX_LENGTH = 80
INDENT = "\t"
@@ -11,14 +12,35 @@ def content_path(name: str) -> Path:
return CONTENT_DIR / name
def load(name: str):
with content_path(name).open(encoding="utf-8") as file:
def data_path(name: str) -> Path:
return DATA_DIR / name
def read_json(path: Path):
with path.open(encoding="utf-8") as file:
return json.load(file)
def write_json(path: Path, data) -> None:
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text(format_value(data, 0) + "\n", encoding="utf-8")
def load(name: str):
return read_json(content_path(name))
def save(name: str, data) -> None:
text = format_value(data, 0) + "\n"
content_path(name).write_text(text, encoding="utf-8")
write_json(content_path(name), data)
def load_data(name: str, default):
path = data_path(name)
return read_json(path) if path.exists() else default
def save_data(name: str, data) -> None:
write_json(data_path(name), data)
def is_primitive(value) -> bool: