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

Method n_import_from37

uncompyle6/semantics/transform.py:393–418  ·  view source on GitHub ↗
(self, node)

Source from the content-addressed store, hash-verified

391 n_ifelsestmtc = n_ifelsestmtl = n_ifelsestmt
392
393 def n_import_from37(self, node):
394 importlist37 = node[3]
395 if importlist37 != "importlist37":
396 return node
397 if len(importlist37) == 1 and importlist37 == "importlist37":
398 alias37 = importlist37[0]
399 store = alias37[1]
400 assert store == "store"
401 alias_name = store[0].attr
402 import_name_attr = node[2]
403 assert import_name_attr == "IMPORT_NAME_ATTR"
404 dotted_names = import_name_attr.attr.split(".")
405 if len(dotted_names) > 1 and dotted_names[-1] == alias_name:
406 # Simulate:
407 # Instead of
408 # import_from37 ::= LOAD_CONST LOAD_CONST IMPORT_NAME_ATTR importlist37 POP_TOP
409 # import_as37 ::= LOAD_CONST LOAD_CONST importlist37 store POP_TOP
410 # 'import_as37': ( '%|import %c as %c\n', 2, -2),
411 node = SyntaxTree(
412 "import_as37",
413 [node[0], node[1], import_name_attr, store, node[-1]],
414 transformed_by="n_import_from37",
415 )
416 pass
417 pass
418 return node
419
420 def n_list_for(self, list_for_node):
421 expr = list_for_node[0]

Callers

nothing calls this directly

Calls 1

SyntaxTreeClass · 0.90

Tested by

no test coverage detected