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

Function n_formatted_value2

uncompyle6/semantics/customize36.py:627–655  ·  view source on GitHub ↗
(node)

Source from the content-addressed store, hash-verified

625 self.n_formatted_value1 = n_formatted_value1
626
627 def n_formatted_value2(node):
628 p = self.prec
629 self.prec = 100
630
631 expr = node[0]
632 assert expr == "expr"
633 old_in_format_string = self.in_format_string
634 self.in_format_string = "formatted_value2"
635 value = self.traverse(expr, indent="")
636 format_value_attr = node[-1]
637 assert format_value_attr == "FORMAT_VALUE_ATTR"
638 attr = format_value_attr.attr
639 if attr & 4:
640 assert node[1] == "expr"
641 fmt = strip_quotes(self.traverse(node[1], indent=""))
642 attr_flags = attr & 3
643 if attr_flags:
644 conversion = "%s:%s" % (FSTRING_CONVERSION_MAP.get(attr_flags, ""), fmt)
645 else:
646 conversion = ":%s" % fmt
647 else:
648 conversion = FSTRING_CONVERSION_MAP.get(attr, "")
649
650 self.in_format_string = old_in_format_string
651 f_str = "f%s" % escape_string("{%s%s}" % (value, conversion))
652 self.write(f_str)
653
654 self.prec = p
655 self.prune()
656
657 self.n_formatted_value2 = n_formatted_value2
658

Callers

nothing calls this directly

Calls 5

strip_quotesFunction · 0.90
escape_stringFunction · 0.90
traverseMethod · 0.45
getMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected