MCPcopy Create free account
hub / github.com/debjitpaul/refiner / decanonicalize_code

Function decanonicalize_code

src/data_processing/canonicalize.py:61–72  ·  view source on GitHub ↗
(code, slot_map)

Source from the content-addressed store, hash-verified

59
60
61def decanonicalize_code(code, slot_map):
62 try:
63 slot2string = {x[0]: x[1]['value'] for x in list(slot_map.items())}
64 py_ast = ast.parse(code)
65 replace_strings_in_ast(py_ast, slot2string)
66 raw_code = astor.to_source(py_ast)
67 # for slot_name, slot_info in slot_map.items():
68 # raw_code = raw_code.replace(slot_name, slot_info['value'])
69
70 return raw_code.strip()
71 except:
72 return code

Callers

nothing calls this directly

Calls 1

replace_strings_in_astFunction · 0.85

Tested by

no test coverage detected