MCPcopy Index your code
hub / github.com/RustPython/RustPython / extract_enum_body

Function extract_enum_body

scripts/generate_opcode_metadata.py:63–72  ·  view source on GitHub ↗
(contents: str, enum_name: str)

Source from the content-addressed store, hash-verified

61
62
63def extract_enum_body(contents: str, enum_name: str) -> str:
64 res = re.search(f"pub enum {enum_name} " + r"\{(.+?)\n\}", contents, re.DOTALL)
65 if not res:
66 raise ValueError(f"Could not find {enum_name} enum")
67
68 return "\n".join(
69 line.split("//")[0].strip() # Remove any comment. i.e. "foo // some comment"
70 for line in res.group(1).splitlines()
71 if not line.strip().startswith("//") # Ignore comment lines
72 )
73
74
75def build_deopts(contents: str) -> dict[str, list[str]]:

Callers 1

Calls 7

searchMethod · 0.45
joinMethod · 0.45
stripMethod · 0.45
splitMethod · 0.45
splitlinesMethod · 0.45
groupMethod · 0.45
startswithMethod · 0.45

Tested by

no test coverage detected