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

Method _fix_sentence_endings

Lib/textwrap.py:179–195  ·  view source on GitHub ↗

_fix_sentence_endings(chunks : [string]) Correct for sentence endings buried in 'chunks'. Eg. when the original text contains "... foo.\\nBar ...", munge_whitespace() and split() will convert that to [..., "foo.", " ", "Bar", ...] which has one too few spaces; this

(self, chunks)

Source from the content-addressed store, hash-verified

177 return chunks
178
179 def _fix_sentence_endings(self, chunks):
180 """_fix_sentence_endings(chunks : [string])
181
182 Correct for sentence endings buried in 'chunks'. Eg. when the
183 original text contains "... foo.\\nBar ...", munge_whitespace()
184 and split() will convert that to [..., "foo.", " ", "Bar", ...]
185 which has one too few spaces; this method simply changes the one
186 space to two.
187 """
188 i = 0
189 patsearch = self.sentence_end_re.search
190 while i < len(chunks)-1:
191 if chunks[i+1] == " " and patsearch(chunks[i]):
192 chunks[i+1] = " "
193 i += 2
194 else:
195 i += 1
196
197 def _handle_long_word(self, reversed_chunks, cur_line, cur_len, width):
198 """_handle_long_word(chunks : [string],

Callers 1

wrapMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected