diff options
author | Barry Warsaw <barry@python.org> | 2002-07-19 22:21:47 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2002-07-19 22:21:47 (GMT) |
commit | d43857455e0f1b33a5b5abfe384c7738f10a63f1 (patch) | |
tree | 6ee23dbc71581a2bf69793fdca2a2846e7333ed7 | |
parent | 1cecdc6bcb3226c2a0a071406e3b06308fbb1369 (diff) | |
download | cpython-d43857455e0f1b33a5b5abfe384c7738f10a63f1.zip cpython-d43857455e0f1b33a5b5abfe384c7738f10a63f1.tar.gz cpython-d43857455e0f1b33a5b5abfe384c7738f10a63f1.tar.bz2 |
_structure(): Take an optional `fp' argument which would be the object
to print>> the structure to. Defaults to sys.stdout.
-rw-r--r-- | Lib/email/Iterators.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Lib/email/Iterators.py b/Lib/email/Iterators.py index 0d0e0b2..d5f6eeb 100644 --- a/Lib/email/Iterators.py +++ b/Lib/email/Iterators.py @@ -4,6 +4,8 @@ """Various types of useful iterators and generators. """ +import sys + try: from email._compat22 import body_line_iterator, typed_subpart_iterator except SyntaxError: @@ -12,10 +14,12 @@ except SyntaxError: -def _structure(msg, level=0): +def _structure(msg, level=0, fp=None): """A handy debugging aid""" + if fp is None: + fp = sys.stdout 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(): for subpart in msg.get_payload(): - _structure(subpart, level+1) + _structure(subpart, level+1, fp) |