29 lines
1.1 KiB
Python
29 lines
1.1 KiB
Python
import os
|
|
|
|
import yaml
|
|
|
|
|
|
class TechnologyManifestError(Exception):
|
|
pass
|
|
|
|
|
|
def technology_manifest_path(pdks_root: str, foundry: str, technology: str) -> str:
|
|
base = os.path.abspath(pdks_root)
|
|
path = os.path.abspath(os.path.join(base, foundry, technology, "technology.yml"))
|
|
if not path.startswith(base + os.sep):
|
|
raise TechnologyManifestError("Invalid technology path")
|
|
return path
|
|
|
|
|
|
def read_technology_manifest(pdks_root: str, foundry: str, technology: str) -> dict:
|
|
path = technology_manifest_path(pdks_root, foundry, technology)
|
|
if not os.path.exists(path):
|
|
raise TechnologyManifestError("technology manifest not generated; run mxpic_forge technology export workflow")
|
|
with open(path, "r", encoding="utf-8") as file:
|
|
manifest = yaml.safe_load(file) or {}
|
|
if not isinstance(manifest.get("xsections"), dict):
|
|
raise TechnologyManifestError("technology manifest is missing xsections")
|
|
if not isinstance(manifest.get("defaults"), dict):
|
|
raise TechnologyManifestError("technology manifest is missing defaults")
|
|
return manifest
|