MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _split_line

Method _split_line

tools/python-3.11.9-amd64/Lib/difflib.py:1755–1808  ·  view source on GitHub ↗

Builds list of text lines by splitting text lines at wrap point This function will determine if the input text line needs to be wrapped (split) into separate lines. If so, the first wrap point will be determined and the first line appended to the output text li

(self,data_list,line_num,text)

Source from the content-addressed store, hash-verified

1753 return fromlines,tolines
1754
1755 def _split_line(self,data_list,line_num,text):
1756 """Builds list of text lines by splitting text lines at wrap point
1757
1758 This function will determine if the input text line needs to be
1759 wrapped (split) into separate lines. If so, the first wrap point
1760 will be determined and the first line appended to the output
1761 text line list. This function is used recursively to handle
1762 the second part of the split line to further split it.
1763 """
1764 # if blank line or context separator, just add it to the output list
1765 if not line_num:
1766 data_list.append((line_num,text))
1767 return
1768
1769 # if line text doesn't need wrapping, just add it to the output list
1770 size = len(text)
1771 max = self._wrapcolumn
1772 if (size <= max) or ((size -(text.count('\0')*3)) <= max):
1773 data_list.append((line_num,text))
1774 return
1775
1776 # scan text looking for the wrap point, keeping track if the wrap
1777 # point is inside markers
1778 i = 0
1779 n = 0
1780 mark = ''
1781 while n < max and i < size:
1782 if text[i] == '\0':
1783 i += 1
1784 mark = text[i]
1785 i += 1
1786 elif text[i] == '\1':
1787 i += 1
1788 mark = ''
1789 else:
1790 i += 1
1791 n += 1
1792
1793 # wrap point is inside text, break it up into separate lines
1794 line1 = text[:i]
1795 line2 = text[i:]
1796
1797 # if wrap point is inside markers, place end marker at end of first
1798 # line and start marker at beginning of second line because each
1799 # line will have its own table tag markup around it.
1800 if mark:
1801 line1 = line1 + '\1'
1802 line2 = '\0' + mark + line2
1803
1804 # tack on first line onto the output list
1805 data_list.append((line_num,line1))
1806
1807 # use this routine again to wrap the remaining text
1808 self._split_line(data_list,'>',line2)
1809
1810 def _line_wrapper(self,diffs):
1811 """Returns iterator that splits (wraps) mdiff text lines"""

Callers 1

_line_wrapperMethod · 0.95

Calls 2

appendMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected