[Python-checkins] python/dist/src/Lib/email Header.py,1.24,1.25
bwarsaw@users.sourceforge.net
bwarsaw@users.sourceforge.net
Mon, 10 Mar 2003 07:14:12 -0800
Update of /cvsroot/python/python/dist/src/Lib/email
In directory sc8-pr-cvs1:/tmp/cvs-serv14235
Modified Files:
Header.py
Log Message:
_split_ascii() [method and function]: Don't join the lines just to
split them again. Simply return them as chunk lists.
_encode_chunks(): Don't add more folding whitespace than necessary.
Index: Header.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/email/Header.py,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** Header.py 7 Mar 2003 23:24:34 -0000 1.24
--- Header.py 10 Mar 2003 15:14:08 -0000 1.25
***************
*** 338,345 ****
def _split_ascii(self, s, charset, firstlen, splitchars):
! line = _split_ascii(s, firstlen, self._maxlinelen,
! self._continuation_ws, splitchars)
! lines = line.splitlines()
! return zip(lines, [charset]*len(lines))
def _encode_chunks(self, newchunks, maxlinelen):
--- 338,344 ----
def _split_ascii(self, s, charset, firstlen, splitchars):
! chunks = _split_ascii(s, firstlen, self._maxlinelen,
! self._continuation_ws, splitchars)
! return zip(chunks, [charset]*len(chunks))
def _encode_chunks(self, newchunks, maxlinelen):
***************
*** 361,365 ****
# =?charset1?q?Mar=EDa_Gonz=E1lez_Alonso?=\n
# =?charset2?b?SvxyZ2VuIEL2aW5n?="
- #
chunks = []
for header, charset in newchunks:
--- 360,363 ----
***************
*** 368,372 ****
else:
s = charset.header_encode(header)
! _max_append(chunks, s, maxlinelen, ' ')
joiner = NL + self._continuation_ws
return joiner.join(chunks)
--- 366,375 ----
else:
s = charset.header_encode(header)
! # Don't add more folding whitespace than necessary
! if chunks and chunks[-1].endswith(' '):
! extra = ''
! else:
! extra = ' '
! _max_append(chunks, s, maxlinelen, extra)
joiner = NL + self._continuation_ws
return joiner.join(chunks)
***************
*** 413,417 ****
def _split_ascii(s, firstlen, restlen, continuation_ws, splitchars):
- linejoiner = '\n' + continuation_ws
lines = []
maxlen = firstlen
--- 416,419 ----
***************
*** 465,471 ****
# on whitespace.
if partlen > maxlen and ch <> ' ':
! subs = _split_ascii(part, maxlen, restlen,
continuation_ws, ' ')
- subl = re.split(linejoiner, subs)
lines.extend(subl[:-1])
this = [subl[-1]]
--- 467,472 ----
# on whitespace.
if partlen > maxlen and ch <> ' ':
! subl = _split_ascii(part, maxlen, restlen,
continuation_ws, ' ')
lines.extend(subl[:-1])
this = [subl[-1]]
***************
*** 480,484 ****
if this:
lines.append(joiner.join(this))
! return linejoiner.join(lines)
--- 481,485 ----
if this:
lines.append(joiner.join(this))
! return lines