INNER CODE UNIT · Python
parse_types
viticci/shortcuts-playground-plugin · claude/skills/shortcuts-playground/scripts/generate_healthkit_reference.py:192
def parse_types(header: Path) -> dict[str, list[dict[str, str]]]:
out: dict[str, list[dict[str, str]]] = {bucket: [] for bucket in TYPE_PREFIXES.values()}
line_re = re.compile(
r"HK_EXTERN\s+"
r"(?P<prefix>HK(?:Quantity|Category|Characteristic|Correlation|Document)TypeIdentifier)"
r"\s+const\s+"
r"(?P<symbol>HK(?:Quantity|Category|Characteristic|Correlation|Document)TypeIdentifier(?P<suffix>[A-Za-z0-9]+))"
r"\s+(?P<availability>.*?);\s*(?://\s*(?P<comment>.*))?$"
)
for raw_line in header.read_text(encoding="utf-8").splitlines():
match = line_re.search(raw_line)
if not match:
continue
bucket = TYPE_PREFIXES[match.group("prefix")]
suffix = match.group("suffix")
symbol = match.group("symbol")
row = {
"symbol": symbol,