| 1 | # Copyright (C) 2001-2004 Python Software Foundation |
| 2 | # Author: Barry Warsaw |
| 3 | # Contact: email-sig@python.org |
| 4 | |
| 5 | """A package for parsing, handling, and generating email messages.""" |
| 6 | |
| 7 | __version__ = '3.0+' |
| 8 | |
| 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', |
| 30 | ] |
| 31 | |
| 32 | |
| 33 | \f |
| 34 | # Some convenience routines. Don't import Parser and Message as side-effects |
| 35 | # of importing email since those cascadingly import most of the rest of the |
| 36 | # email package. |
| 37 | def message_from_string(s, *args, **kws): |
| 38 | """Parse a string into a Message object model. |
| 39 | |
| 40 | Optional _class and strict are passed to the Parser constructor. |
| 41 | """ |
| 42 | from email.Parser import Parser |
| 43 | return Parser(*args, **kws).parsestr(s) |
| 44 | |
| 45 | |
| 46 | def message_from_file(fp, *args, **kws): |
| 47 | """Read a file and parse its contents into a Message object model. |
| 48 | |
| 49 | Optional _class and strict are passed to the Parser constructor. |
| 50 | """ |
| 51 | from email.Parser import Parser |
| 52 | return Parser(*args, **kws).parse(fp) |