INNER CODE UNIT · Python

parse_category_values

viticci/shortcuts-playground-plugin · claude/skills/shortcuts-playground/scripts/generate_healthkit_reference.py:232

def parse_category_values(header: Path) -> dict[str, list[dict[str, object]]]:
    text = header.read_text(encoding="utf-8")
    enum_re = re.compile(
        r"typedef NS_ENUM\(NSInteger,\s*(?P<enum>HKCategoryValue[A-Za-z0-9]+)\)\s*\{(?P<body>.*?)\}",
        re.S,
    )
    out: dict[str, list[dict[str, object]]] = {}
    for enum_match in enum_re.finditer(text):
        enum_name = enum_match.group("enum")
        values: list[dict[str, object]] = []
        previous_int: int | None = None
        for raw_line in enum_match.group("body").splitlines():
            line = raw_line.strip()
            if not line.startswith("HKCategoryValue"):
                continue
            const = line.split(None, 1)[0].rstrip(",")
            expr = None
            if "=" in line:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…