MCPcopy
hub / github.com/rocky/python-uncompyle6 / deparsed_find

Function deparsed_find

uncompyle6/semantics/fragments.py:2254–2275  ·  view source on GitHub ↗

Return a NodeInfo nametuple for a fragment-deparsed `deparsed` at `tup`. `tup` is a name and offset tuple, `deparsed` is a fragment object and `code` is instruction bytecode.

(tup, deparsed, code)

Source from the content-addressed store, hash-verified

2252
2253
2254def deparsed_find(tup, deparsed, code):
2255 """Return a NodeInfo nametuple for a fragment-deparsed `deparsed` at `tup`.
2256
2257 `tup` is a name and offset tuple, `deparsed` is a fragment object
2258 and `code` is instruction bytecode."""
2259 nodeInfo = None
2260 name, last_i = tup
2261 if not hasattr(deparsed, "offsets"):
2262 return None
2263 if (name, last_i) in deparsed.offsets.keys():
2264 nodeInfo = deparsed.offsets[name, last_i]
2265 else:
2266 from uncompyle6.scanner import get_scanner
2267
2268 scanner = get_scanner(deparsed.version)
2269 co = code.co_code
2270 if op_at_code_loc(co, last_i, scanner.opc) == "DUP_TOP":
2271 offset = deparsed.scanner.next_offset(co[last_i], last_i)
2272 if (name, offset) in deparsed.offsets:
2273 nodeInfo = deparsed.offsets[name, offset]
2274
2275 return nodeInfo
2276
2277
2278# if __name__ == "__main__":

Callers

nothing calls this directly

Calls 4

get_scannerFunction · 0.90
op_at_code_locFunction · 0.85
next_offsetMethod · 0.80
keysMethod · 0.45

Tested by

no test coverage detected