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

Function replace_compiled

crates/sre_engine/generate_tests.py:60–67  ·  view source on GitHub ↗
(m)

Source from the content-addressed store, hash-verified

58
59
60def replace_compiled(m):
61 line, indent, varname, pattern = m.groups()
62 pattern = eval(pattern, {"re": CompiledPattern})
63 pattern = f"Pattern {{ pattern: {rust_str(pattern.pattern)}, code: &{json.dumps(pattern.code)} }}"
64 return f"""{line}
65{indent}// START GENERATED by generate_tests.py
66{indent}#[rustfmt::skip] let {varname} = {pattern};
67{indent}// END GENERATED"""
68
69
70with os.scandir("tests") as t, os.scandir("benches") as b:

Callers

nothing calls this directly

Calls 4

rust_strFunction · 0.85
evalFunction · 0.50
groupsMethod · 0.45
dumpsMethod · 0.45

Tested by

no test coverage detected