Guido van Rossum | 8b3febe | 2007-08-30 01:15:14 +0000 | [diff] [blame] | 1 | # Copyright (C) 2001-2007 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__ = '5.0.0' |
| 8 | |
| 9 | __all__ = [ |
| 10 | 'base64mime', |
| 11 | 'charset', |
| 12 | 'encoders', |
| 13 | 'errors', |
| 14 | 'generator', |
| 15 | 'header', |
| 16 | 'iterators', |
| 17 | 'message', |
| 18 | 'message_from_file', |
| 19 | 'message_from_string', |
| 20 | 'mime', |
| 21 | 'parser', |
| 22 | 'quoprimime', |
| 23 | 'utils', |
| 24 | ] |
| 25 | |
| 26 | |
| 27 | |
| 28 | # Some convenience routines. Don't import Parser and Message as side-effects |
| 29 | # of importing email since those cascadingly import most of the rest of the |
| 30 | # email package. |
| 31 | def message_from_string(s, *args, **kws): |
| 32 | """Parse a string into a Message object model. |
| 33 | |
| 34 | Optional _class and strict are passed to the Parser constructor. |
| 35 | """ |
| 36 | from email.parser import Parser |
| 37 | return Parser(*args, **kws).parsestr(s) |
| 38 | |
| 39 | |
| 40 | def message_from_file(fp, *args, **kws): |
| 41 | """Read a file and parse its contents into a Message object model. |
| 42 | |
| 43 | Optional _class and strict are passed to the Parser constructor. |
| 44 | """ |
| 45 | from email.parser import Parser |
| 46 | return Parser(*args, **kws).parse(fp) |