| 545 | ) |
| 546 | |
| 547 | def parse(self, fmt_string: str) -> Iterator[Tuple[Any, Any, Any, Any]]: |
| 548 | for literal_txt, field_name, format_spec, conversion in Formatter.parse( |
| 549 | self, fmt_string |
| 550 | ): |
| 551 | # Find $foo patterns in the literal text. |
| 552 | continue_from = 0 |
| 553 | txt = "" |
| 554 | for m in self._dollar_pattern_ignore_single_quote.finditer(literal_txt): |
| 555 | new_txt, new_field = m.group(1,2) |
| 556 | # $$foo --> $foo |
| 557 | if new_field.startswith("$"): |
| 558 | txt += new_txt + new_field |
| 559 | else: |
| 560 | yield (txt + new_txt, new_field, "", None) |
| 561 | txt = "" |
| 562 | continue_from = m.end() |
| 563 | |
| 564 | # Re-yield the {foo} style pattern |
| 565 | yield (txt + literal_txt[continue_from:], field_name, format_spec, conversion) |
| 566 | |
| 567 | def __repr__(self) -> str: |
| 568 | return "<DollarFormatter>" |