(self, fmt_string)
| 590 | """ |
| 591 | _dollar_pattern_ignore_single_quote = re.compile(r"(.*?)\$(\$?[\w\.]+)(?=([^']*'[^']*')*[^']*$)") |
| 592 | def parse(self, fmt_string): |
| 593 | for literal_txt, field_name, format_spec, conversion \ |
| 594 | in Formatter.parse(self, fmt_string): |
| 595 | |
| 596 | # Find $foo patterns in the literal text. |
| 597 | continue_from = 0 |
| 598 | txt = "" |
| 599 | for m in self._dollar_pattern_ignore_single_quote.finditer(literal_txt): |
| 600 | new_txt, new_field = m.group(1,2) |
| 601 | # $$foo --> $foo |
| 602 | if new_field.startswith("$"): |
| 603 | txt += new_txt + new_field |
| 604 | else: |
| 605 | yield (txt + new_txt, new_field, "", None) |
| 606 | txt = "" |
| 607 | continue_from = m.end() |
| 608 | |
| 609 | # Re-yield the {foo} style pattern |
| 610 | yield (txt + literal_txt[continue_from:], field_name, format_spec, conversion) |
| 611 | |
| 612 | #----------------------------------------------------------------------------- |
| 613 | # Utils to columnize a list of string |
no test coverage detected