Barry Warsaw | 409a4c0 | 2002-04-10 21:01:31 +0000 | [diff] [blame] | 1 | # Copyright (C) 2001,2002 Python Software Foundation |
Barry Warsaw | ba92580 | 2001-09-23 03:17:28 +0000 | [diff] [blame] | 2 | # Author: barry@zope.com (Barry Warsaw) |
| 3 | |
| 4 | """Various types of useful iterators and generators. |
| 5 | """ |
| 6 | |
Barry Warsaw | 8c1aac2 | 2002-05-19 23:44:19 +0000 | [diff] [blame] | 7 | try: |
| 8 | from email._compat22 import body_line_iterator, typed_subpart_iterator |
| 9 | except SyntaxError: |
| 10 | # Python 2.1 doesn't have generators |
| 11 | from email._compat21 import body_line_iterator, typed_subpart_iterator |
Barry Warsaw | 8fa06b5 | 2002-07-09 02:39:07 +0000 | [diff] [blame] | 12 | |
| 13 | |
| 14 | |
| 15 | def _structure(msg, level=0): |
| 16 | """A handy debugging aid""" |
| 17 | tab = ' ' * (level * 4) |
Barry Warsaw | 4ef1c7d | 2002-07-11 20:24:36 +0000 | [diff] [blame] | 18 | print tab + msg.get_type(msg.get_default_type()) |
Barry Warsaw | 8fa06b5 | 2002-07-09 02:39:07 +0000 | [diff] [blame] | 19 | if msg.is_multipart(): |
| 20 | for subpart in msg.get_payload(): |
| 21 | _structure(subpart, level+1) |