This commit was manufactured by cvs2svn to create tag 'r234c1'.
[python/dscho.git] / Lib / email / __init__.py
blobbfd6105529315f7ad6492170626f4178881bd827
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.
5 """
7 __version__ = '2.5.4'
9 __all__ = [
10 'base64MIME',
11 'Charset',
12 'Encoders',
13 'Errors',
14 'Generator',
15 'Header',
16 'Iterators',
17 'Message',
18 'MIMEAudio',
19 'MIMEBase',
20 'MIMEImage',
21 'MIMEMessage',
22 'MIMEMultipart',
23 'MIMENonMultipart',
24 'MIMEText',
25 'Parser',
26 'quopriMIME',
27 'Utils',
28 'message_from_string',
29 'message_from_file',
32 try:
33 True, False
34 except NameError:
35 True = 1
36 False = 0
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
42 # email package.
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.
47 """
48 from email.Parser import Parser
49 if _class is None:
50 from email.Message import Message
51 _class = 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.
58 """
59 from email.Parser import Parser
60 if _class is None:
61 from email.Message import Message
62 _class = 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