[Zope3-checkins] CVS: Zope/lib/python/ZConfig - datatypes.py:1.13
Fred L. Drake, Jr.
fred@zope.com
Mon, 24 Mar 2003 15:52:40 -0500
Update of /cvs-repository/Zope/lib/python/ZConfig
In directory cvs.zope.org:/tmp/cvs-serv3491
Modified Files:
datatypes.py
Log Message:
- remove helpers that are no longer used
- don't assume Python was built with Unicode support
=== Zope/lib/python/ZConfig/datatypes.py 1.12 => 1.13 ===
--- Zope/lib/python/ZConfig/datatypes.py:1.12 Mon Mar 24 15:47:25 2003
+++ Zope/lib/python/ZConfig/datatypes.py Mon Mar 24 15:52:39 2003
@@ -17,6 +17,14 @@
import re
import sys
+# types.StringTypes was added in Python 2.2
+try:
+ unicode
+except NameError:
+ StringTypes = type(''), type(unicode(''))
+else:
+ StringTypes = type(''),
+
try:
True
except NameError:
@@ -165,7 +173,7 @@
self.address = inet_address(s)
def float_conversion(v):
- if isinstance(v, type('')) or isinstance(v, type(u'')):
+ if type(v) in StringTypes:
if v.lower() in ["inf", "-inf", "nan"]:
raise ValueError(`v` + " is not a portable float representation")
return float(v)
@@ -209,42 +217,6 @@
return v
raise ValueError, ('The directory named as part of the path %s '
'does not exist.' % v)
-
-def parse_constructor(v):
- parenmsg = (
- 'Invalid constructor (unbalanced parenthesis in "%s")' % v
- )
- openparen = v.find('(')
- if openparen < 0:
- raise ValueError(parenmsg)
- klass = v[:openparen]
- if not v.endswith(')'):
- raise ValueError(parenmsg)
- arglist = v[openparen+1:-1]
- return klass, arglist
-
-def get_arglist(s):
- # someone could do a better job at this.
- pos = []
- kw = {}
- args = s.split(',')
- args = filter(None, args)
- while args:
- arg = args.pop(0)
- try:
- if '=' in arg:
- k,v=arg.split('=', 1)
- k = k.strip()
- v = v.strip()
- kw[k] = eval(v)
- else:
- arg = arg.strip()
- pos.append(eval(arg))
- except SyntaxError:
- if not args:
- raise
- args[0] = '%s, %s' % (arg, args[0])
- return pos, kw
class SuffixMultiplier: