MCPcopy Create free account
hub / github.com/ipython/ipython / parse

Method parse

IPython/utils/text.py:592–610  ·  view source on GitHub ↗
(self, fmt_string)

Source from the content-addressed store, hash-verified

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

Callers 9

vformatMethod · 0.45
push_accepts_moreMethod · 0.45
_async_parse_cellFunction · 0.45
_ast_asyncifyFunction · 0.45
timeitMethod · 0.45
extract_symbolsFunction · 0.45
process_pure_pythonMethod · 0.45
_parse_moduleMethod · 0.45

Calls 1

groupMethod · 0.80

Tested by

no test coverage detected