summaryrefslogtreecommitdiffstats
path: root/Lib/email/Utils.py
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2002-05-19 23:44:19 (GMT)
committerBarry Warsaw <barry@python.org>2002-05-19 23:44:19 (GMT)
commit8c1aac247667e6ac146e9153cd2941e4c5ec7b09 (patch)
tree4ed2ee7b3470d19d54d99d61f7509d3d4c5777bf /Lib/email/Utils.py
parent2ae87539aad20670184ff9d30f625dddd6ac2e78 (diff)
downloadcpython-8c1aac247667e6ac146e9153cd2941e4c5ec7b09.zip
cpython-8c1aac247667e6ac146e9153cd2941e4c5ec7b09.tar.gz
cpython-8c1aac247667e6ac146e9153cd2941e4c5ec7b09.tar.bz2
Complete a merge of the mimelib project and the Python cvs codebases
for the email package. The former is now just a shell project that has some extra files for packaging for independent use (e.g. setup.py and README). Added a compatibility layer so that the same API can be used in Python 2.1 and 2.2/2.3 with the major differences shuffled off into helper modules (_compat21.py and _compat22.py). Also bumped the package version number to 2.0.3 for some fixes to be checked in momentarily.
Diffstat (limited to 'Lib/email/Utils.py')
-rw-r--r--Lib/email/Utils.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/Lib/email/Utils.py b/Lib/email/Utils.py
index 927d67e..a2b6c87 100644
--- a/Lib/email/Utils.py
+++ b/Lib/email/Utils.py
@@ -21,7 +21,24 @@ from rfc822 import mktime_tz
from rfc822 import parsedate as _parsedate
from rfc822 import parsedate_tz as _parsedate_tz
-from quopri import decodestring as _qdecode
+try:
+ from quopri import decodestring as _qdecode
+except ImportError:
+ # Python 2.1 doesn't have quopri.decodestring()
+ def _qdecode(s):
+ import quopri as _quopri
+
+ if not s:
+ return s
+ hasnewline = (s[-1] == '\n')
+ infp = StringIO(s)
+ outfp = StringIO()
+ _quopri.decode(infp, outfp)
+ value = outfp.getvalue()
+ if not hasnewline and value[-1] =='\n':
+ return value[:-1]
+ return value
+
import base64
# Intrapackage imports