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

Method from_str

scripts/generate_opcode_metadata.py:48–54  ·  view source on GitHub ↗
(cls, body: str)

Source from the content-addressed store, hash-verified

46
47 @classmethod
48 def from_str(cls, body: str):
49 raw_variants = re.split(r"(\d+),", body.strip())
50 raw_variants.remove("")
51 for raw_name, raw_id in itertools.batched(raw_variants, 2, strict=True):
52 have_oparg = "Arg<" in raw_name # Hacky but works
53 name = re.findall(r"\b[A-Z][A-Za-z]*\d*\b(?=\s*[\({=])", raw_name)[0]
54 yield cls(rust_name=name.strip(), id=int(raw_id), have_oparg=have_oparg)
55
56 def __lt__(self, other: typing.Self) -> bool:
57 sprio, oprio = (

Callers 1

Calls 5

clsClass · 0.50
splitMethod · 0.45
stripMethod · 0.45
removeMethod · 0.45
findallMethod · 0.45

Tested by

no test coverage detected