Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /GRID-INTELLIGENCE_GRID /safety /rules /loader.py
| import json | |
| from pathlib import Path | |
| from typing import Any | |
| import yaml | |
| def load_rules(rule_file_path: str | Path | None = None) -> list[dict[str, Any]]: | |
| """ | |
| Load safety rules from JSON or YAML file. | |
| Args: | |
| rule_file_path: Path to the rule file. If None, checks registry.json then defaults.yaml. | |
| Returns: | |
| List of rule dictionaries. | |
| """ | |
| if rule_file_path is None: | |
| # Check Project GUARDIAN registry first, then fallback to defaults | |
| p_json = Path(__file__).parent / "registry.json" | |
| p_yaml = Path(__file__).parent / "defaults.yaml" | |
| rule_file_path = p_json if p_json.exists() else p_yaml | |
| path = Path(rule_file_path) | |
| if not path.exists(): | |
| return [] | |
| try: | |
| with open(path, encoding="utf-8") as f: | |
| if path.suffix.lower() == ".json": | |
| data = json.load(f) | |
| else: | |
| data = yaml.safe_load(f) | |
| return data.get("rules", []) | |
| except Exception as e: | |
| # Use simple print as fallback if logging not ready | |
| print(f"Failed to load rules from {path}: {e}") | |
| return [] | |
Xet Storage Details
- Size:
- 1.14 kB
- Xet hash:
- 171dd0a1e81d4a2a57e95143b60a6b363e508ba7d363035d75292803e9a14c29
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.