Serialize key-value dictionary to paragraph text.
(self, message: dict)
| 63 | return result |
| 64 | |
| 65 | def dump(self, message: dict) -> str: |
| 66 | """Serialize key-value dictionary to paragraph text.""" |
| 67 | |
| 68 | if isinstance(message, str): |
| 69 | return message |
| 70 | |
| 71 | def _indent_block(text: str) -> str: |
| 72 | if not text: |
| 73 | return "" |
| 74 | return "\n".join(f" {line}" for line in text.splitlines()) |
| 75 | |
| 76 | result_lines: list[str] = [] |
| 77 | for key, value in message.items(): |
| 78 | result_lines.append(f"{key}:") |
| 79 | if value is not None: |
| 80 | if isinstance(value, str): |
| 81 | rendered = value |
| 82 | else: |
| 83 | rendered = _indent_block(self.render_value(value)) |
| 84 | result_lines.append(rendered) |
| 85 | |
| 86 | return "\n".join(result_lines).strip() |
nothing calls this directly
no test coverage detected