Mercurial > cpython-lru_cache-weakref
annotate Lib/email/Iterators.py @ 24149:7bcd8177628f legacy-trunk
_structure(): A handy little debugging aid that I don't (yet) intend
to make public, but that others might still find useful.
| author | Barry Warsaw <barry@python.org> |
|---|---|
| date | Tue, 09 Jul 2002 02:39:07 +0000 |
| parents | 077d44b0405b |
| children | 774dc07f1c16 |
| rev | line source |
|---|---|
|
22939
534aab5bccea
Sync'ing with standalone email package 2.0.1. This adds support for
Barry Warsaw <barry@python.org>
parents:
20426
diff
changeset
|
1 # Copyright (C) 2001,2002 Python Software Foundation |
|
20042
e08f423f9165
The email package version 1.0, prototyped as mimelib
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
2 # Author: barry@zope.com (Barry Warsaw) |
|
e08f423f9165
The email package version 1.0, prototyped as mimelib
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
3 |
|
e08f423f9165
The email package version 1.0, prototyped as mimelib
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
4 """Various types of useful iterators and generators. |
|
e08f423f9165
The email package version 1.0, prototyped as mimelib
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
5 """ |
|
e08f423f9165
The email package version 1.0, prototyped as mimelib
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
6 |
|
23473
077d44b0405b
Complete a merge of the mimelib project and the Python cvs codebases
Barry Warsaw <barry@python.org>
parents:
22939
diff
changeset
|
7 try: |
|
077d44b0405b
Complete a merge of the mimelib project and the Python cvs codebases
Barry Warsaw <barry@python.org>
parents:
22939
diff
changeset
|
8 from email._compat22 import body_line_iterator, typed_subpart_iterator |
|
077d44b0405b
Complete a merge of the mimelib project and the Python cvs codebases
Barry Warsaw <barry@python.org>
parents:
22939
diff
changeset
|
9 except SyntaxError: |
|
077d44b0405b
Complete a merge of the mimelib project and the Python cvs codebases
Barry Warsaw <barry@python.org>
parents:
22939
diff
changeset
|
10 # Python 2.1 doesn't have generators |
|
077d44b0405b
Complete a merge of the mimelib project and the Python cvs codebases
Barry Warsaw <barry@python.org>
parents:
22939
diff
changeset
|
11 from email._compat21 import body_line_iterator, typed_subpart_iterator |
|
24149
7bcd8177628f
_structure(): A handy little debugging aid that I don't (yet) intend
Barry Warsaw <barry@python.org>
parents:
23473
diff
changeset
|
12 |
|
7bcd8177628f
_structure(): A handy little debugging aid that I don't (yet) intend
Barry Warsaw <barry@python.org>
parents:
23473
diff
changeset
|
13 |
|
7bcd8177628f
_structure(): A handy little debugging aid that I don't (yet) intend
Barry Warsaw <barry@python.org>
parents:
23473
diff
changeset
|
14 |
|
7bcd8177628f
_structure(): A handy little debugging aid that I don't (yet) intend
Barry Warsaw <barry@python.org>
parents:
23473
diff
changeset
|
15 def _structure(msg, level=0): |
|
7bcd8177628f
_structure(): A handy little debugging aid that I don't (yet) intend
Barry Warsaw <barry@python.org>
parents:
23473
diff
changeset
|
16 """A handy debugging aid""" |
|
7bcd8177628f
_structure(): A handy little debugging aid that I don't (yet) intend
Barry Warsaw <barry@python.org>
parents:
23473
diff
changeset
|
17 tab = ' ' * (level * 4) |
|
7bcd8177628f
_structure(): A handy little debugging aid that I don't (yet) intend
Barry Warsaw <barry@python.org>
parents:
23473
diff
changeset
|
18 print tab + msg.get('content-type', msg.get_default_type()) |
|
7bcd8177628f
_structure(): A handy little debugging aid that I don't (yet) intend
Barry Warsaw <barry@python.org>
parents:
23473
diff
changeset
|
19 if msg.is_multipart(): |
|
7bcd8177628f
_structure(): A handy little debugging aid that I don't (yet) intend
Barry Warsaw <barry@python.org>
parents:
23473
diff
changeset
|
20 for subpart in msg.get_payload(): |
|
7bcd8177628f
_structure(): A handy little debugging aid that I don't (yet) intend
Barry Warsaw <barry@python.org>
parents:
23473
diff
changeset
|
21 _structure(subpart, level+1) |
