Spaces:
Sleeping
Sleeping
Download app/dataops/package_loader.py from TheJackBright/polyguard-openenv: direct link, hf CLI and curl.
- Browser
- Download file 526 Bytes
-
https://huggingface.co/spaces/TheJackBright/polyguard-openenv/resolve/main/app/dataops/package_loader.py
- Command line
-
hf download hf://spaces/TheJackBright/polyguard-openenv/app/dataops/package_loader.py
-
curl -L -o package_loader.py https://huggingface.co/spaces/TheJackBright/polyguard-openenv/resolve/main/app/dataops/package_loader.py
526 Bytes
| """Package/local artifact loading.""" | |
| from __future__ import annotations | |
| import json | |
| from pathlib import Path | |
| from typing import Any | |
| import yaml | |
| def load_artifact(path: Path) -> Any: | |
| if path.suffix.lower() in {".json"}: | |
| return json.loads(path.read_text(encoding="utf-8")) | |
| if path.suffix.lower() in {".yaml", ".yml"}: | |
| return yaml.safe_load(path.read_text(encoding="utf-8")) | |
| if path.suffix.lower() in {".txt", ".md"}: | |
| return path.read_text(encoding="utf-8") | |
| return path.read_bytes() | |