Download stackgo/stackbuild/repo_serialization.py from s0duku/the-stack-go: direct link, hf CLI and curl.
- Browser
- Download file 535 Bytes
-
https://huggingface.co/datasets/s0duku/the-stack-go/resolve/main/stackgo/stackbuild/repo_serialization.py
- Command line
-
hf download hf://datasets/s0duku/the-stack-go/stackgo/stackbuild/repo_serialization.py
-
curl -L -o repo_serialization.py https://huggingface.co/datasets/s0duku/the-stack-go/resolve/main/stackgo/stackbuild/repo_serialization.py
535 Bytes
| """Stable JSON representation for RepoInfo artifacts.""" | |
| from __future__ import annotations | |
| from dataclasses import asdict | |
| import json | |
| from pathlib import Path | |
| from .repo_model import RepoInfo | |
| def to_dict(info: RepoInfo) -> dict: | |
| return asdict(info) | |
| def write_json(info: RepoInfo, path: str | Path) -> None: | |
| target = Path(path) | |
| temporary = target.with_suffix(target.suffix + ".part") | |
| temporary.write_text(json.dumps(to_dict(info), ensure_ascii=False, separators=(",", ":")) + "\n") | |
| temporary.replace(target) | |