(self, node, is_format_spec=False)
| 633 | self._write_ftstring(node.values, "t") |
| 634 | |
| 635 | def _write_ftstring_inner(self, node, is_format_spec=False): |
| 636 | if isinstance(node, JoinedStr): |
| 637 | # for both the f-string itself, and format_spec |
| 638 | for value in node.values: |
| 639 | self._write_ftstring_inner(value, is_format_spec=is_format_spec) |
| 640 | elif isinstance(node, Constant) and isinstance(node.value, str): |
| 641 | value = node.value.replace("{", "{{").replace("}", "}}") |
| 642 | |
| 643 | if is_format_spec: |
| 644 | value = value.replace("\\", "\\\\") |
| 645 | value = value.replace("'", "\\'") |
| 646 | value = value.replace('"', '\\"') |
| 647 | value = value.replace("\n", "\\n") |
| 648 | self.write(value) |
| 649 | elif isinstance(node, FormattedValue): |
| 650 | self.visit_FormattedValue(node) |
| 651 | elif isinstance(node, Interpolation): |
| 652 | self.visit_Interpolation(node) |
| 653 | else: |
| 654 | raise ValueError(f"Unexpected node inside JoinedStr, {node!r}") |
| 655 | |
| 656 | def _unparse_interpolation_value(self, inner): |
| 657 | unparser = type(self)() |
no test coverage detected