Pull URLab's hand-rolled ``EMj*`` enums out of the merged introspect snapshot when present. Snapshot path produces real ENUM_CONSTANT_DECL members from libclang. Regex fallback covers the local-dev case where the snapshot wasn't regenerated.
(mjspec: Optional[Dict[str, Any]])
| 67 | |
| 68 | |
| 69 | def _hand_enums_from_snapshot(mjspec: Optional[Dict[str, Any]]) -> Dict[str, List[str]]: |
| 70 | """Pull URLab's hand-rolled ``EMj*`` enums out of the merged |
| 71 | introspect snapshot when present. Snapshot path produces real |
| 72 | ENUM_CONSTANT_DECL members from libclang. Regex fallback covers |
| 73 | the local-dev case where the snapshot wasn't regenerated.""" |
| 74 | if not mjspec: |
| 75 | return {} |
| 76 | introspect = mjspec.get("introspect", {}) or {} |
| 77 | hand_enums = introspect.get("hand_enums") or {} |
| 78 | out: Dict[str, List[str]] = {} |
| 79 | for name, entry in hand_enums.items(): |
| 80 | if not isinstance(entry, dict): |
| 81 | continue |
| 82 | members = entry.get("members", {}) |
| 83 | if isinstance(members, dict): |
| 84 | out[name] = list(members.keys()) |
| 85 | return out |
| 86 | |
| 87 | |
| 88 | # --------------------------------------------------------------------------- |
no outgoing calls
no test coverage detected