Kaydet (Commit) d4385745 authored tarafından Barry Warsaw's avatar Barry Warsaw

_structure(): Take an optional `fp' argument which would be the object

to print>> the structure to.  Defaults to sys.stdout.
üst 1cecdc6b
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
"""Various types of useful iterators and generators. """Various types of useful iterators and generators.
""" """
import sys
try: try:
from email._compat22 import body_line_iterator, typed_subpart_iterator from email._compat22 import body_line_iterator, typed_subpart_iterator
except SyntaxError: except SyntaxError:
...@@ -12,10 +14,12 @@ except SyntaxError: ...@@ -12,10 +14,12 @@ except SyntaxError:
def _structure(msg, level=0): def _structure(msg, level=0, fp=None):
"""A handy debugging aid""" """A handy debugging aid"""
if fp is None:
fp = sys.stdout
tab = ' ' * (level * 4) tab = ' ' * (level * 4)
print tab + msg.get_type(msg.get_default_type()) print >> fp, tab + msg.get_type(msg.get_default_type())
if msg.is_multipart(): if msg.is_multipart():
for subpart in msg.get_payload(): for subpart in msg.get_payload():
_structure(subpart, level+1) _structure(subpart, level+1, fp)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment