| 
									
										
										
										
											2002-04-10 21:01:31 +00:00
										 |  |  |  | # Copyright (C) 2001,2002 Python Software Foundation | 
					
						
							| 
									
										
										
										
											2001-09-23 03:17:28 +00:00
										 |  |  |  | # Author: barry@zope.com (Barry Warsaw) | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | """Various types of useful iterators and generators.
 | 
					
						
							|  |  |  |  | """
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-07-19 22:21:47 +00:00
										 |  |  |  | import sys | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-05-19 23:44:19 +00:00
										 |  |  |  | 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 | 
					
						
							| 
									
										
										
										
											2002-07-09 02:39:07 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |  | 
					
						
							| 
									
										
										
										
											2002-07-19 22:21:47 +00:00
										 |  |  |  | def _structure(msg, level=0, fp=None): | 
					
						
							| 
									
										
										
										
											2002-07-09 02:39:07 +00:00
										 |  |  |  |     """A handy debugging aid""" | 
					
						
							| 
									
										
										
										
											2002-07-19 22:21:47 +00:00
										 |  |  |  |     if fp is None: | 
					
						
							|  |  |  |  |         fp = sys.stdout | 
					
						
							| 
									
										
										
										
											2002-07-09 02:39:07 +00:00
										 |  |  |  |     tab = ' ' * (level * 4) | 
					
						
							| 
									
										
										
										
											2002-09-01 21:04:43 +00:00
										 |  |  |  |     print >> fp, tab + msg.get_content_type() | 
					
						
							| 
									
										
										
										
											2002-07-09 02:39:07 +00:00
										 |  |  |  |     if msg.is_multipart(): | 
					
						
							|  |  |  |  |         for subpart in msg.get_payload(): | 
					
						
							| 
									
										
										
										
											2002-07-19 22:21:47 +00:00
										 |  |  |  |             _structure(subpart, level+1, fp) |