1 # Copyright (C) 2001,2002 Python Software Foundation
2 # Author: barry@zope.com (Barry Warsaw)
4 """A package for parsing, handling, and generating email messages.
28 'message_from_string',
40 # Some convenience routines. Don't import Parser and Message as side-effects
41 # of importing email since those cascadingly import most of the rest of the
43 def message_from_string(s
, _class
=None, strict
=False):
44 """Parse a string into a Message object model.
46 Optional _class and strict are passed to the Parser constructor.
48 from email
.Parser
import Parser
50 from email
.Message
import Message
52 return Parser(_class
, strict
=strict
).parsestr(s
)
54 def message_from_file(fp
, _class
=None, strict
=False):
55 """Read a file and parse its contents into a Message object model.
57 Optional _class and strict are passed to the Parser constructor.
59 from email
.Parser
import Parser
61 from email
.Message
import Message
63 return Parser(_class
, strict
=strict
).parse(fp
)
67 # Patch encodings.aliases to recognize 'ansi_x3.4_1968' which isn't a standard
68 # alias in Python 2.1.3, but is used by the email package test suite.
69 from encodings
.aliases
import aliases
# The aliases dictionary
70 if not aliases
.has_key('ansi_x3.4_1968'):
71 aliases
['ansi_x3.4_1968'] = 'ascii'
72 del aliases
# Not needed any more