MCPcopy Index your code
hub / github.com/python/cpython / _qformat

Method _qformat

Lib/difflib.py:1002–1027  ·  view source on GitHub ↗

r""" Format "?" output and deal with tabs. Example: >>> d = Differ() >>> results = d._qformat('\tabcDefghiJkl\n', '\tabcdefGhijkl\n', ... ' ^ ^ ^ ', ' ^ ^ ^ ') >>> for line in results: print(repr(line)) ...

(self, aline, bline, atags, btags)

Source from the content-addressed store, hash-verified

1000 yield from g
1001
1002 def _qformat(self, aline, bline, atags, btags):
1003 r"""
1004 Format "?" output and deal with tabs.
1005
1006 Example:
1007
1008 >>> d = Differ()
1009 >>> results = d._qformat('\tabcDefghiJkl\n', '\tabcdefGhijkl\n',
1010 ... ' ^ ^ ^ ', ' ^ ^ ^ ')
1011 >>> for line in results: print(repr(line))
1012 ...
1013 '- \tabcDefghiJkl\n'
1014 '? \t ^ ^ ^\n'
1015 '+ \tabcdefGhijkl\n'
1016 '? \t ^ ^ ^\n'
1017 """
1018 atags = _keep_original_ws(aline, atags).rstrip()
1019 btags = _keep_original_ws(bline, btags).rstrip()
1020
1021 yield "- " + aline
1022 if atags:
1023 yield f"? {atags}\n"
1024
1025 yield "+ " + bline
1026 if btags:
1027 yield f"? {btags}\n"
1028
1029# With respect to junk, an earlier version of ndiff simply refused to
1030# *start* a match with a junk element. The result was cases like this:

Callers 1

_fancy_replaceMethod · 0.95

Calls 2

_keep_original_wsFunction · 0.85
rstripMethod · 0.45

Tested by

no test coverage detected