File: Iterators.py

package info (click to toggle)
python2.2 2.2.3dfsg-2sarge1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 36,920 kB
  • ctags: 69,127
  • sloc: ansic: 219,839; python: 203,969; sh: 9,690; makefile: 3,468; perl: 3,454; lisp: 3,248; xml: 2,262; cpp: 106; sed: 2
file content (25 lines) | stat: -rw-r--r-- 686 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Copyright (C) 2001,2002 Python Software Foundation
# Author: barry@zope.com (Barry Warsaw)

"""Various types of useful iterators and generators.
"""

import sys

try:
    from email._compat22 import body_line_iterator, typed_subpart_iterator
except SyntaxError:
    # Python 2.1 doesn't have generators
    from email._compat21 import body_line_iterator, typed_subpart_iterator



def _structure(msg, fp=None, level=0):
    """A handy debugging aid"""
    if fp is None:
        fp = sys.stdout
    tab = ' ' * (level * 4)
    print >> fp, tab + msg.get_content_type()
    if msg.is_multipart():
        for subpart in msg.get_payload():
            _structure(subpart, fp, level+1)