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

Method print_super_classes3

uncompyle6/semantics/pysource.py:589–666  ·  view source on GitHub ↗
(self, node)

Source from the content-addressed store, hash-verified

587 self.write(")")
588
589 def print_super_classes3(self, node):
590 n = len(node) - 1
591 j = 0
592 if node.kind != "expr":
593 if node == "kwarg":
594 self.template_engine(("(%[0]{attr}=%c)", 1), node)
595 return
596
597 kwargs = None
598 assert node[n].kind.startswith("CALL_FUNCTION")
599
600 if node[n].kind.startswith("CALL_FUNCTION_KW"):
601 if self.is_pypy:
602 # FIXME: this doesn't handle positional and keyword args
603 # properly. Need to do something more like that below
604 # in the non-PYPY 3.6 case.
605 self.template_engine(("(%[0]{attr}=%c)", 1), node[n - 1])
606 return
607 else:
608 kwargs = node[n - 1].attr
609
610 assert isinstance(kwargs, tuple)
611 i = n - (len(kwargs) + 1)
612 j = 1 + n - node[n].attr
613 else:
614 i = start = n - 2
615 for i in range(start, 0, -1):
616 if not node[i].kind in ["expr", "call", "LOAD_CLASSNAME"]:
617 break
618 pass
619
620 if i == start:
621 return
622 i += 2
623
624 line_separator = ", "
625 sep = ""
626 self.write("(")
627 if kwargs:
628 # Last arg is tuple of keyword values: omit
629 m = n - 1
630 else:
631 m = n
632
633 if kwargs:
634 # 3.6+ does this
635 while j < i:
636 self.write(sep)
637 value = self.traverse(node[j])
638 self.write("%s" % value)
639 sep = line_separator
640 j += 1
641
642 j = 0
643 while i < m:
644 self.write(sep)
645 value = self.traverse(node[i])
646 self.write("%s=%s" % (kwargs[j], value))

Callers 2

n_classdef36Function · 0.45
n_classdef3Function · 0.45

Calls 3

template_engineMethod · 0.95
writeMethod · 0.95
traverseMethod · 0.95

Tested by

no test coverage detected