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

Function n_formatted_value_debug

uncompyle6/semantics/customize38.py:303–347  ·  view source on GitHub ↗
(node)

Source from the content-addressed store, hash-verified

301 self.n_set_afor = n_set_afor
302
303 def n_formatted_value_debug(node):
304 p = self.prec
305 self.prec = 100
306
307 formatted_value = node[1]
308 value_equal = node[0].attr
309 assert formatted_value.kind.startswith("formatted_value")
310 old_in_format_string = self.in_format_string
311 self.in_format_string = formatted_value.kind
312 format_value_attr = node[-1]
313
314 post_str = ""
315 if node[-1] == "BUILD_STRING_3":
316 post_load_str = node[-2]
317 post_str = self.traverse(post_load_str, indent="")
318 post_str = strip_quotes(post_str)
319
320 if format_value_attr == "FORMAT_VALUE_ATTR":
321 attr = format_value_attr.attr
322 if attr & 4:
323 fmt = strip_quotes(self.traverse(node[3], indent=""))
324 attr_flags = attr & 3
325 if attr_flags:
326 conversion = "%s:%s" % (
327 FSTRING_CONVERSION_MAP.get(attr_flags, ""),
328 fmt,
329 )
330 else:
331 conversion = ":%s" % fmt
332 else:
333 conversion = FSTRING_CONVERSION_MAP.get(attr, "")
334 f_str = "f%s" % escape_string(
335 "{%s%s}%s" % (value_equal, conversion, post_str)
336 )
337 else:
338 f_conversion = self.traverse(formatted_value, indent="")
339 # Remove leaving "f" and quotes
340 conversion = strip_quotes(f_conversion[1:])
341 f_str = "f%s" % escape_string(f"{value_equal}{conversion}" + post_str)
342
343 self.write(f_str)
344 self.in_format_string = old_in_format_string
345
346 self.prec = p
347 self.prune()
348
349 self.n_formatted_value_debug = n_formatted_value_debug
350

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