INNER CODE UNIT · Python
load_yaml
awslabs/awsome-distributed-ai · .github/scripts/stage-template-publish.py:42
def load_yaml(path: Path) -> Any:
with path.open("r", encoding="utf-8") as handle:
return yaml.load(handle, Loader=CfnTagLoader)
def is_cloudformation_template(path: Path) -> bool:
try:
document = load_yaml(path)
except yaml.YAMLError as exc:
raise ValueError(f"{path}: invalid YAML: {exc}") from exc
return isinstance(document, dict) and isinstance(document.get("Resources"), dict)
def normalize_key(key: str) -> str:
key = key.strip().lstrip("/")
if not key:
raise ValueError("empty S3 key")
if ".." in Path(key).parts: