summaryrefslogtreecommitdiffstats
path: root/Lib/email
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2002-05-23 15:15:30 (GMT)
committerTim Peters <tim.peters@gmail.com>2002-05-23 15:15:30 (GMT)
commit8ac1495a6a1d18111a626cec0c7f2eb67df3edb3 (patch)
tree2d91993770d3a5b3f3668857983d9bf75276b14f /Lib/email
parentf655328483b2e237cc2f71c1c308eceb2f30f6fd (diff)
downloadcpython-8ac1495a6a1d18111a626cec0c7f2eb67df3edb3.zip
cpython-8ac1495a6a1d18111a626cec0c7f2eb67df3edb3.tar.gz
cpython-8ac1495a6a1d18111a626cec0c7f2eb67df3edb3.tar.bz2
Whitespace normalization.
Diffstat (limited to 'Lib/email')
-rw-r--r--Lib/email/Charset.py8
-rw-r--r--Lib/email/Header.py8
-rw-r--r--Lib/email/Message.py2
-rw-r--r--Lib/email/Utils.py2
-rw-r--r--Lib/email/base64MIME.py26
-rw-r--r--Lib/email/quopriMIME.py8
6 files changed, 27 insertions, 27 deletions
diff --git a/Lib/email/Charset.py b/Lib/email/Charset.py
index 4874597..0de5f80 100644
--- a/Lib/email/Charset.py
+++ b/Lib/email/Charset.py
@@ -13,7 +13,7 @@ QP = 1 # Quoted-Printable
BASE64 = 2 # Base64
# In "=?charset?q?hello_world?=", the =?, ?q?, and ?= add up to 7
-MISC_LEN = 7
+MISC_LEN = 7
DEFAULT_CHARSET = 'us-ascii'
@@ -22,11 +22,11 @@ DEFAULT_CHARSET = 'us-ascii'
# Defaults
CHARSETS = {
# input header enc body enc output conv
- 'iso-8859-1': (QP, QP, None),
+ 'iso-8859-1': (QP, QP, None),
'iso-8859-2': (QP, QP, None),
'us-ascii': (None, None, None),
'big5': (BASE64, BASE64, None),
- 'gb2312': (BASE64, BASE64, None),
+ 'gb2312': (BASE64, BASE64, None),
'euc-jp': (BASE64, None, 'iso-2022-jp'),
'shift_jis': (BASE64, None, 'iso-2022-jp'),
'iso-2022-jp': (BASE64, None, None),
@@ -125,7 +125,7 @@ class Charset:
converting between character sets, given the availability of the
applicable codecs. Given an character set, it will do its best to provide
information on how to use that character set in an email.
-
+
Certain character sets must be encoded with quoted-printable or base64
when used in email headers or bodies. Certain character sets must be
converted outright, and are not allowed in email. Instances of this
diff --git a/Lib/email/Header.py b/Lib/email/Header.py
index fb8792c..95b5a37 100644
--- a/Lib/email/Header.py
+++ b/Lib/email/Header.py
@@ -61,7 +61,7 @@ def decode_header(header):
if not ecre.search(line):
decoded.append((line, None))
continue
-
+
parts = ecre.split(line)
while parts:
unenc = parts.pop(0).strip()
@@ -149,14 +149,14 @@ class Header:
if charset is None:
charset = self._charset
self._chunks.append((s, charset))
-
+
def _split(self, s, charset):
# Split up a header safely for use with encode_chunks. BAW: this
# appears to be a private convenience method.
splittable = charset.to_splittable(s)
encoded = charset.from_splittable(splittable)
elen = charset.encoded_header_len(encoded)
-
+
if elen <= self._maxlinelen:
return [(encoded, charset)]
# BAW: should we use encoded?
@@ -185,7 +185,7 @@ class Header:
Base64 or quoted-printable) header strings. In addition, there is a
75-character length limit on any given encoded header field, so
line-wrapping must be performed, even with double-byte character sets.
-
+
This method will do its best to convert the string to the correct
character set used in email, and encode and line wrap it safely with
the appropriate scheme for that character set.
diff --git a/Lib/email/Message.py b/Lib/email/Message.py
index 6cb659c..84a4e16 100644
--- a/Lib/email/Message.py
+++ b/Lib/email/Message.py
@@ -216,7 +216,7 @@ class Message:
def get_charset(self):
"""Return the Charset object associated with the message's payload."""
return self._charset
-
+
#
# MAPPING INTERFACE (partial)
#
diff --git a/Lib/email/Utils.py b/Lib/email/Utils.py
index 99a65f9..0c57392 100644
--- a/Lib/email/Utils.py
+++ b/Lib/email/Utils.py
@@ -88,7 +88,7 @@ def formataddr(pair):
"""The inverse of parseaddr(), this takes a 2-tuple of the form
(realname, email_address) and returns the string value suitable
for an RFC 2822 From:, To: or Cc:.
-
+
If the first element of pair is false, then the second element is
returned unmodified.
"""
diff --git a/Lib/email/base64MIME.py b/Lib/email/base64MIME.py
index 08420b2..11979e3 100644
--- a/Lib/email/base64MIME.py
+++ b/Lib/email/base64MIME.py
@@ -39,20 +39,20 @@ MISC_LEN = 7
# Helpers
def base64_len(s):
"""Return the length of s when it is encoded with base64."""
- groups_of_3, leftover = divmod(len(s), 3)
- # 4 bytes out for each 3 bytes (or nonzero fraction thereof) in.
+ groups_of_3, leftover = divmod(len(s), 3)
+ # 4 bytes out for each 3 bytes (or nonzero fraction thereof) in.
# Thanks, Tim!
- n = groups_of_3 * 4
- if leftover:
- n += 4
- return n
+ n = groups_of_3 * 4
+ if leftover:
+ n += 4
+ return n
def header_encode(header, charset='iso-8859-1', keep_eols=0, maxlinelen=76,
eol=NL):
"""Encode a single header line with Base64 encoding in a given charset.
-
+
Defined in RFC 2045, this Base64 encoding is identical to normal Base64
encoding, except that each line must be intelligently wrapped (respecting
the Base64 encoding), and subsequent lines must start with a space.
@@ -72,7 +72,7 @@ def header_encode(header, charset='iso-8859-1', keep_eols=0, maxlinelen=76,
"=?charset?b?WW/5ciBtYXp66XLrIHf8eiBhIGhhbXBzdGHuciBBIFlv+XIgbWF6euly?=\\n
=?charset?b?6yB3/HogYSBoYW1wc3Rh7nIgQkMgWW/5ciBtYXp66XLrIHf8eiBhIGhh?="
-
+
with each line wrapped at, at most, maxlinelen characters (defaults to 76
characters).
"""
@@ -82,7 +82,7 @@ def header_encode(header, charset='iso-8859-1', keep_eols=0, maxlinelen=76,
if not keep_eols:
header = fix_eols(header)
-
+
# Base64 encode each line, in encoded chunks no greater than maxlinelen in
# length, after the RFC chrome is added in.
base64ed = []
@@ -91,7 +91,7 @@ def header_encode(header, charset='iso-8859-1', keep_eols=0, maxlinelen=76,
# BAW: Ben's original code used a step of max_unencoded, but I think it
# ought to be max_encoded. Otherwise, where's max_encoded used? I'm
- # still not sure what the
+ # still not sure what the
for i in range(0, len(header), max_unencoded):
base64ed.append(b2a_base64(header[i:i+max_unencoded]))
@@ -126,10 +126,10 @@ def encode(s, binary=1, maxlinelen=76, eol=NL):
"""
if not s:
return s
-
+
if not binary:
s = fix_eols(s)
-
+
encvec = []
max_unencoded = maxlinelen * 3 / 4
for i in range(0, len(s), max_unencoded):
@@ -162,7 +162,7 @@ def decode(s, convert_eols=None):
"""
if not s:
return s
-
+
dec = a2b_base64(s)
if convert_eols:
return dec.replace(CRLF, convert_eols)
diff --git a/Lib/email/quopriMIME.py b/Lib/email/quopriMIME.py
index 002034e..afd2e5e 100644
--- a/Lib/email/quopriMIME.py
+++ b/Lib/email/quopriMIME.py
@@ -22,7 +22,7 @@ in To:/From:/Cc: etc. fields, as well as Subject: lines.
This module does not do the line wrapping or end-of-line character
conversion necessary for proper internationalized headers; it only
does dumb encoding and decoding. To deal with the various line
-wrapping issues, use the email.Header module.
+wrapping issues, use the email.Header module.
"""
import re
@@ -50,7 +50,7 @@ def body_quopri_check(c):
"""Return true if the character should be escaped with body quopri."""
return bqre.match(c) and 1
-
+
def header_quopri_len(s):
"""Return the length of str when it is encoded with header quopri."""
count = 0
@@ -131,7 +131,7 @@ def header_encode(header, charset="iso-8859-1", keep_eols=0, maxlinelen=76,
# lenght, after the RFC chrome is added in.
quoted = []
max_encoded = maxlinelen - len(charset) - MISC_LEN
-
+
for c in header:
# Space may be represented as _ instead of =20 for readability
if c == ' ':
@@ -187,7 +187,7 @@ def encode(body, binary=0, maxlinelen=76, eol=NL):
line = line[:-2]
elif line[-1] in CRLF:
line = line[:-1]
-
+
lineno += 1
encoded_line = ''
prev = None