please update the "basic usage" page
Bug #1213721 reported by
Alexandru Toth
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
flufl.bounce |
Opinion
|
Wishlist
|
Unassigned |
Bug Description
Hi,
Can't find a better way to post this message.
Please update the examples page with a script that runs. It took some time to dig thru the test.py to find out what exactly is the parse() function, and what to include to make the snippet run.
After all of this, discovered that there is text above the Python snipped telling the same thing. An import would had been better than all the prose.
from email import message_from_string as parse
from flufl.bounce import scan_message
mail_with_headers = '...'
msg = parse(mail_
recipients = scan_message(msg)
print recipients
Many thanks for developing this project!
Alexandru Toth
www.snowflakejo
To post a comment you must log in.
The .rst files are the Sphynx source for the manual (See, e.g. <http:// pythonhosted. org/flufl. bounce/ README. html>) and the code snippetstherein are actually doctests run by the command 'python setup.py test'.
The issue is that the parse() function is different depending on whether the Python is 2 or 3 (email. message_ from_string if Python 2 and email.message_ from_bytes igf Python 3) so the definition of parse is relegated to the test modules.
The doctest could include code like
try:
# Python 3
from email import message_from_bytes as parse
except ImportError:
# Python 2
from email import message_from_string as parse
to work either way, but in essence it is documentation and not intended to be a complete working example, and I think it's better as it is.