OLD | NEW |
(Empty) | |
| 1 # Copyright (C) 2001-2007 Python Software Foundation |
| 2 # Author: Barry Warsaw |
| 3 # Contact: email-sig@python.org |
| 4 |
| 5 """ |
| 6 Backport of the Python 3.3 email package for Python-Future. |
| 7 |
| 8 A package for parsing, handling, and generating email messages. |
| 9 """ |
| 10 from __future__ import unicode_literals |
| 11 from __future__ import division |
| 12 from __future__ import absolute_import |
| 13 |
| 14 # Install the surrogate escape handler here because this is used by many |
| 15 # modules in the email package. |
| 16 from future.utils import surrogateescape |
| 17 surrogateescape.register_surrogateescape() |
| 18 # (Should this be done globally by ``future``?) |
| 19 |
| 20 |
| 21 __version__ = '5.1.0' |
| 22 |
| 23 __all__ = [ |
| 24 'base64mime', |
| 25 'charset', |
| 26 'encoders', |
| 27 'errors', |
| 28 'feedparser', |
| 29 'generator', |
| 30 'header', |
| 31 'iterators', |
| 32 'message', |
| 33 'message_from_file', |
| 34 'message_from_binary_file', |
| 35 'message_from_string', |
| 36 'message_from_bytes', |
| 37 'mime', |
| 38 'parser', |
| 39 'quoprimime', |
| 40 'utils', |
| 41 ] |
| 42 |
| 43 |
| 44 |
| 45 # Some convenience routines. Don't import Parser and Message as side-effects |
| 46 # of importing email since those cascadingly import most of the rest of the |
| 47 # email package. |
| 48 def message_from_string(s, *args, **kws): |
| 49 """Parse a string into a Message object model. |
| 50 |
| 51 Optional _class and strict are passed to the Parser constructor. |
| 52 """ |
| 53 from future.backports.email.parser import Parser |
| 54 return Parser(*args, **kws).parsestr(s) |
| 55 |
| 56 def message_from_bytes(s, *args, **kws): |
| 57 """Parse a bytes string into a Message object model. |
| 58 |
| 59 Optional _class and strict are passed to the Parser constructor. |
| 60 """ |
| 61 from future.backports.email.parser import BytesParser |
| 62 return BytesParser(*args, **kws).parsebytes(s) |
| 63 |
| 64 def message_from_file(fp, *args, **kws): |
| 65 """Read a file and parse its contents into a Message object model. |
| 66 |
| 67 Optional _class and strict are passed to the Parser constructor. |
| 68 """ |
| 69 from future.backports.email.parser import Parser |
| 70 return Parser(*args, **kws).parse(fp) |
| 71 |
| 72 def message_from_binary_file(fp, *args, **kws): |
| 73 """Read a binary file and parse its contents into a Message object model. |
| 74 |
| 75 Optional _class and strict are passed to the Parser constructor. |
| 76 """ |
| 77 from future.backports.email.parser import BytesParser |
| 78 return BytesParser(*args, **kws).parse(fp) |
OLD | NEW |