Initial import with GitLab CI/CD and registry deploy flow

This commit is contained in:
Yera All
2026-04-02 17:05:45 +05:00
commit 5374c202d9
338 changed files with 81297 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
from __future__ import annotations
import copy
import json
import os
from pathlib import Path
from tempfile import NamedTemporaryFile
from typing import Any
def _data_dir() -> Path:
root = Path(os.getenv("CC_DATA_DIR", ".data")).resolve()
root.mkdir(parents=True, exist_ok=True)
return root
def _file_path(name: str) -> Path:
safe = name.replace("\\", "_").replace("/", "_")
return _data_dir() / safe
def load_json(name: str, default: Any) -> Any:
path = _file_path(name)
if not path.exists():
return copy.deepcopy(default)
try:
return json.loads(path.read_text(encoding="utf-8"))
except Exception:
return copy.deepcopy(default)
def save_json(name: str, data: Any) -> None:
path = _file_path(name)
path.parent.mkdir(parents=True, exist_ok=True)
with NamedTemporaryFile("w", encoding="utf-8", delete=False, dir=str(path.parent)) as tmp:
json.dump(data, tmp, ensure_ascii=False, indent=2)
tmp_path = Path(tmp.name)
tmp_path.replace(path)