INNER CODE UNIT · Python

value_label

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

def value_label(enum_name: str, constant: str) -> str:
    suffix = constant
    if constant.startswith(enum_name):
        suffix = constant[len(enum_name) :]
    elif constant.startswith("HKCategoryValue"):
        suffix = constant[len("HKCategoryValue") :]
    return split_camel(suffix)


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")

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…