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

Method _append_chunk

Lib/email/header.py:512–542  ·  view source on GitHub ↗
(self, fws, string)

Source from the content-addressed store, hash-verified

510 self._append_chunk(fws, part)
511
512 def _append_chunk(self, fws, string):
513 self._current_line.push(fws, string)
514 if len(self._current_line) > self._maxlen:
515 # Find the best split point, working backward from the end.
516 # There might be none, on a long first line.
517 for ch in self._splitchars:
518 for i in range(self._current_line.part_count()-1, 0, -1):
519 if ch.isspace():
520 fws = self._current_line[i][0]
521 if fws and fws[0]==ch:
522 break
523 prevpart = self._current_line[i-1][1]
524 if prevpart and prevpart[-1]==ch:
525 break
526 else:
527 continue
528 break
529 else:
530 fws, part = self._current_line.pop()
531 if self._current_line._initial_size > 0:
532 # There will be a header, so leave it on a line by itself.
533 self.newline()
534 if not fws:
535 # We don't use continuation_ws here because the whitespace
536 # after a header should always be a space.
537 fws = ' '
538 self._current_line.push(fws, part)
539 return
540 remainder = self._current_line.pop_from(i)
541 self._lines.append(str(self._current_line))
542 self._current_line.reset(remainder)
543
544
545class _Accumulator(list):

Callers 2

feedMethod · 0.95
_ascii_splitMethod · 0.95

Calls 9

newlineMethod · 0.95
strFunction · 0.85
part_countMethod · 0.80
isspaceMethod · 0.80
pop_fromMethod · 0.80
pushMethod · 0.45
popMethod · 0.45
appendMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected