[CMF-checkins] CVS: CMF/CMFDefault - utils.py:1.21
Yvo Schubbe
cvs-admin at zope.org
Mon Dec 1 04:11:28 EST 2003
Update of /cvs-repository/CMF/CMFDefault
In directory cvs.zope.org:/tmp/cvs-serv32076/CMFDefault
Modified Files:
utils.py
Log Message:
- made tuplize() work with unicode strings
- fixed default splitter
- enabled tuplize() and seq_strip() tests
=== CMF/CMFDefault/utils.py 1.20 => 1.21 ===
--- CMF/CMFDefault/utils.py:1.20 Thu Sep 25 07:36:49 2003
+++ CMF/CMFDefault/utils.py Mon Dec 1 04:11:18 2003
@@ -16,6 +16,7 @@
"""
from sgmllib import SGMLParser
+from types import ListType, StringType, TupleType, UnicodeType
import re
import os
@@ -134,27 +135,26 @@
security.declarePublic('seq_strip')
def seq_strip(seq, stripper=lambda x: x.strip() ):
-
""" Strip a sequence of strings.
"""
- if type( seq ) == type( [] ):
+ if isinstance(seq, ListType):
return map( stripper, seq )
- if type( seq ) == type( () ):
+ if isinstance(seq, TupleType):
return tuple( map( stripper, seq ) )
raise ValueError, "%s of unsupported sequencetype %s" % ( seq, type( seq ) )
security.declarePublic('tuplize')
-def tuplize( valueName, value, splitter=lambda x: x.strip() ):
+def tuplize( valueName, value, splitter=lambda x: x.split() ):
- if type( value ) == type( () ):
+ if isinstance(value, TupleType):
return seq_strip( value )
- if type( value ) == type( [] ):
+ if isinstance(value, ListType):
return seq_strip( tuple( value ) )
- if type( value ) == type( '' ):
+ if isinstance(value, StringType) or isinstance(value, UnicodeType):
return seq_strip( tuple( splitter( value ) ) )
raise ValueError, "%s of unsupported type" % valueName
More information about the CMF-checkins
mailing list