Revision: 3256
http://spambayes.svn.sourceforge.net/spambayes/?rev=3256&view=rev
Author: montanaro
Date: 2009-12-18 13:01:12 +0000 (Fri, 18 Dec 2009)
Log Message:
-----------
revert - it borks the From_ line...
Modified Paths:
--------------
trunk/spambayes/spambayes/mboxutils.py
trunk/spambayes/spambayes/message.py
Modified: trunk/spambayes/spambayes/mboxutils.py
===================================================================
--- trunk/spambayes/spambayes/mboxutils.py 2009-12-06 19:36:06 UTC (rev
3255)
+++ trunk/spambayes/spambayes/mboxutils.py 2009-12-18 13:01:12 UTC (rev
3256)
@@ -171,22 +171,20 @@
shouldn't matter.
"""
- from spambayes.message import Message
-
- if isinstance(obj, Message):
+ if isinstance(obj, email.Message.Message):
return obj
# Create an email Message object.
if hasattr(obj, "read"):
obj = obj.read()
try:
- msg = email.message_from_string(obj, _class=Message)
+ msg = email.message_from_string(obj)
except email.Errors.MessageParseError:
# Wrap the raw text in a bare Message object. Since the
# headers are most likely damaged, we can't use the email
# package to parse them, so just get rid of them first.
headers = extract_headers(obj)
obj = obj[len(headers):]
- msg = Message()
+ msg = email.Message.Message()
msg.set_payload(obj)
return msg
@@ -205,23 +203,10 @@
bit of rearranging, but that should work nicely, and mean that all
this code is together in one place.
"""
-
- from spambayes.message import Message
-
if isinstance(msg, str):
return msg
-
- if isinstance(msg, Message):
- return msg.as_string()
-
try:
- warnings.warn("Use spambayes.message.Message instead")
- import email.generator
- import StringIO
- f = StringIO.StringIO()
- gen = email.generator.Generator(f, mangle_from_=False)
- gen.flatten(msg)
- return f.getvalue()
+ return msg.as_string(unixfrom)
except TypeError:
ty, val, tb = sys.exc_info()
exclines = traceback.format_exception(ty, val, tb)[1:]
Modified: trunk/spambayes/spambayes/message.py
===================================================================
--- trunk/spambayes/spambayes/message.py 2009-12-06 19:36:06 UTC (rev
3255)
+++ trunk/spambayes/spambayes/message.py 2009-12-18 13:01:12 UTC (rev
3256)
@@ -415,7 +415,7 @@
"""Make sure data uses CRLF for line termination."""
return CRLF_RE.sub('\r\n', data)
- def as_string(self, unixfrom=False, mangle_from_=False):
+ def as_string(self, unixfrom=False, mangle_from_=True):
# The email package stores line endings in the "internal" Python
# format ('\n'). It is up to whoever transmits that information to
# convert to appropriate line endings (according to RFC822, that is
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Spambayes-checkins mailing list
[email protected]
http://mail.python.org/mailman/listinfo/spambayes-checkins