mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 03:44:55 +00:00 
			
		
		
		
	typed_subpart_iterator(): Fix these to use non-deprecated APIs,
i.e. get_content_maintype() and get_content_subtype(). Also, add True, False for Python 2.2.x where x < 2 compatibility.
This commit is contained in:
		
							parent
							
								
									8af56778fd
								
							
						
					
					
						commit
						cd7051f698
					
				
					 1 changed files with 10 additions and 3 deletions
				
			
		| 
						 | 
					@ -1,7 +1,7 @@
 | 
				
			||||||
# Copyright (C) 2002 Python Software Foundation
 | 
					# Copyright (C) 2002 Python Software Foundation
 | 
				
			||||||
# Author: barry@zope.com
 | 
					# Author: barry@zope.com
 | 
				
			||||||
 | 
					
 | 
				
			||||||
"""Module containing compatibility functions for Python 2.1.
 | 
					"""Module containing compatibility functions for Python 2.2.
 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from __future__ import generators
 | 
					from __future__ import generators
 | 
				
			||||||
| 
						 | 
					@ -9,6 +9,13 @@ from __future__ import division
 | 
				
			||||||
from cStringIO import StringIO
 | 
					from cStringIO import StringIO
 | 
				
			||||||
from types import StringTypes
 | 
					from types import StringTypes
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Python 2.2.x where x < 2 lacks True/False
 | 
				
			||||||
 | 
					try:
 | 
				
			||||||
 | 
					    True, False
 | 
				
			||||||
 | 
					except NameError:
 | 
				
			||||||
 | 
					    True = 1
 | 
				
			||||||
 | 
					    False = 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# This function will become a method of the Message class
 | 
					# This function will become a method of the Message class
 | 
				
			||||||
| 
						 | 
					@ -58,6 +65,6 @@ def typed_subpart_iterator(msg, maintype='text', subtype=None):
 | 
				
			||||||
    omitted, only the main type is matched.
 | 
					    omitted, only the main type is matched.
 | 
				
			||||||
    """
 | 
					    """
 | 
				
			||||||
    for subpart in msg.walk():
 | 
					    for subpart in msg.walk():
 | 
				
			||||||
        if subpart.get_main_type('text') == maintype:
 | 
					        if subpart.get_content_maintype() == maintype:
 | 
				
			||||||
            if subtype is None or subpart.get_subtype('plain') == subtype:
 | 
					            if subtype is None or subpart.get_content_subtype() == subtype:
 | 
				
			||||||
                yield subpart
 | 
					                yield subpart
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue