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

Function n_formatted_value1

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

Source from the content-addressed store, hash-verified

598 return node.conversion
599
600 def n_formatted_value1(node):
601 expr = node[0]
602 assert expr == "expr"
603 conversion = f_conversion(node)
604 if self.in_format_string and self.in_format_string != "formatted_value1":
605 value = self.traverse(expr, indent="")
606 if value[0] == "{":
607 # If we have a set or dictionary comprehension, then we need to add a space
608 # so as not to confuse the format string with {{.
609 fmt = "{ %s%s }"
610 else:
611 fmt = "{%s%s}"
612 es = escape_string(fmt % (value, conversion))
613 f_str = "%s" % es
614 else:
615 old_in_format_string = self.in_format_string
616 self.in_format_string = "formatted_value1"
617 value = self.traverse(expr, indent="")
618 self.in_format_string = old_in_format_string
619 es = escape_string("{%s%s}" % (value, conversion))
620 f_str = "f%s" % es
621
622 self.write(f_str)
623 self.prune()
624
625 self.n_formatted_value1 = n_formatted_value1
626

Callers

nothing calls this directly

Calls 4

escape_stringFunction · 0.90
f_conversionFunction · 0.85
traverseMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected