Mercurial > cpython-lru_cache-weakref
annotate Lib/email/Iterators.py @ 27998:e27f58a50737 legacy-trunk
SF bug #690377: Dud footnote reference in distutils docs
| author | Raymond Hettinger <python@rcn.com> |
|---|---|
| date | Fri, 21 Feb 2003 02:47:09 +0000 |
| parents | 2d80bf65cd09 |
| children | 635ef110658e |
| 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 |
|
24331
697777cc83cc
_structure(): Take an optional `fp' argument which would be the object
Barry Warsaw <barry@python.org>
parents:
24201
diff
changeset
|
7 import sys |
|
697777cc83cc
_structure(): Take an optional `fp' argument which would be the object
Barry Warsaw <barry@python.org>
parents:
24201
diff
changeset
|
8 |
|
23473
077d44b0405b
Complete a merge of the mimelib project and the Python cvs codebases
Barry Warsaw <barry@python.org>
parents:
22939
diff
changeset
|
9 try: |
|
077d44b0405b
Complete a merge of the mimelib project and the Python cvs codebases
Barry Warsaw <barry@python.org>
parents:
22939
diff
changeset
|
10 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
|
11 except SyntaxError: |
|
077d44b0405b
Complete a merge of the mimelib project and the Python cvs codebases
Barry Warsaw <barry@python.org>
parents:
22939
diff
changeset
|
12 # 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
|
13 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
|
14 |
|
7bcd8177628f
_structure(): A handy little debugging aid that I don't (yet) intend
Barry Warsaw <barry@python.org>
parents:
23473
diff
changeset
|
15 |
|
7bcd8177628f
_structure(): A handy little debugging aid that I don't (yet) intend
Barry Warsaw <barry@python.org>
parents:
23473
diff
changeset
|
16 |
|
25509
2d80bf65cd09
_structure(): Swap fp and level arguments.
Barry Warsaw <barry@python.org>
parents:
25088
diff
changeset
|
17 def _structure(msg, fp=None, level=0): |
|
24149
7bcd8177628f
_structure(): A handy little debugging aid that I don't (yet) intend
Barry Warsaw <barry@python.org>
parents:
23473
diff
changeset
|
18 """A handy debugging aid""" |
|
24331
697777cc83cc
_structure(): Take an optional `fp' argument which would be the object
Barry Warsaw <barry@python.org>
parents:
24201
diff
changeset
|
19 if fp is None: |
|
697777cc83cc
_structure(): Take an optional `fp' argument which would be the object
Barry Warsaw <barry@python.org>
parents:
24201
diff
changeset
|
20 fp = sys.stdout |
|
24149
7bcd8177628f
_structure(): A handy little debugging aid that I don't (yet) intend
Barry Warsaw <barry@python.org>
parents:
23473
diff
changeset
|
21 tab = ' ' * (level * 4) |
|
25088
19982c5eb493
_structure(): Use .get_content_type()
Barry Warsaw <barry@python.org>
parents:
24331
diff
changeset
|
22 print >> fp, tab + msg.get_content_type() |
|
24149
7bcd8177628f
_structure(): A handy little debugging aid that I don't (yet) intend
Barry Warsaw <barry@python.org>
parents:
23473
diff
changeset
|
23 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
|
24 for subpart in msg.get_payload(): |
|
25509
2d80bf65cd09
_structure(): Swap fp and level arguments.
Barry Warsaw <barry@python.org>
parents:
25088
diff
changeset
|
25 _structure(subpart, fp, level+1) |
