Mercurial > cpython-lru_cache-weakref
diff Lib/email/Iterators.py @ 24331:697777cc83cc legacy-trunk
_structure(): Take an optional `fp' argument which would be the object
to print>> the structure to. Defaults to sys.stdout.
| author | Barry Warsaw <barry@python.org> |
|---|---|
| date | Fri, 19 Jul 2002 22:21:47 +0000 |
| parents | 774dc07f1c16 |
| children | 19982c5eb493 |
line wrap: on
line diff
--- a/Lib/email/Iterators.py Fri Jul 19 22:21:02 2002 +0000 +++ b/Lib/email/Iterators.py Fri Jul 19 22:21:47 2002 +0000 @@ -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 @@ -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)
