[Greater-commits] r3639 - in trunk/GREAT-ER/SciParam: . UI
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Fri Jul 22 12:04:58 CEST 2011
Author: aheinecke
Date: 2011-07-22 12:04:57 +0200 (Fri, 22 Jul 2011)
New Revision: 3639
Modified:
trunk/GREAT-ER/SciParam/UI/dialog.py
trunk/GREAT-ER/SciParam/UI/notebook.py
trunk/GREAT-ER/SciParam/distribution.py
trunk/GREAT-ER/SciParam/parameter.py
Log:
Make sciparam work with unicode
Modified: trunk/GREAT-ER/SciParam/UI/dialog.py
===================================================================
--- trunk/GREAT-ER/SciParam/UI/dialog.py 2011-07-22 09:38:12 UTC (rev 3638)
+++ trunk/GREAT-ER/SciParam/UI/dialog.py 2011-07-22 10:04:57 UTC (rev 3639)
@@ -97,7 +97,7 @@
length_list.append(1)
parameter_list.append(par)
elif type(par) == types.TupleType and len(par) == 2 and \
- (par[0] is None or type(par[0]) == types.StringType) and \
+ (par[0] is None or isinstance(par[0], basestring)) and \
(type(par[1]) == types.ListType and len(par[1])) and \
reduce(lambda ok, x: ok and isinstance(x, SciParam), par[1]):
length_list.append(len(par[1]))
Modified: trunk/GREAT-ER/SciParam/UI/notebook.py
===================================================================
--- trunk/GREAT-ER/SciParam/UI/notebook.py 2011-07-22 09:38:12 UTC (rev 3638)
+++ trunk/GREAT-ER/SciParam/UI/notebook.py 2011-07-22 10:04:57 UTC (rev 3639)
@@ -131,7 +131,7 @@
parameter_list = []
for page in parameter:
if type(page) == types.TupleType and len(page) == 2 and \
- type(page[0]) == types.StringType:
+ isinstance(page[0], basestring):
par, par_list = ParameterDialog.parse_param(self, page[1],
columns)
parsed.append((page[0], par))
Modified: trunk/GREAT-ER/SciParam/distribution.py
===================================================================
--- trunk/GREAT-ER/SciParam/distribution.py 2011-07-22 09:38:12 UTC (rev 3638)
+++ trunk/GREAT-ER/SciParam/distribution.py 2011-07-22 10:04:57 UTC (rev 3639)
@@ -59,7 +59,7 @@
raise ValueError, ("Illegal number of descriptives: %s"
" (should be: %s)"
% (len(value), self.descriptives_len()))
- elif type(value) == types.StringType:
+ elif isinstance(value, basestring):
parts = value.split('/')
if len(parts) == 2:
value, self.type = parts
@@ -76,7 +76,7 @@
elif name == 'type':
if value is None:
value = self.none
- elif type(value) == types.StringType:
+ elif isinstance(value, basestring):
value = value.strip().lower()
if value not in self.types:
raise ValueError, "not a distribution type: %s" % (value,)
Modified: trunk/GREAT-ER/SciParam/parameter.py
===================================================================
--- trunk/GREAT-ER/SciParam/parameter.py 2011-07-22 09:38:12 UTC (rev 3638)
+++ trunk/GREAT-ER/SciParam/parameter.py 2011-07-22 10:04:57 UTC (rev 3639)
@@ -133,7 +133,7 @@
if self.is1unknown(value):
return self.unknown[0]
else:
- return str(value)
+ return unicode(value)
def normalize(self, value, default=None):
"""Convert string to normalized string.
@@ -197,7 +197,7 @@
usual=1: check for usual range
"""
- if type(value) == types.StringType:
+ if isinstance(value, basestring):
value = self.convert(value)
if usual:
inrange = value in self.wrange
@@ -257,7 +257,8 @@
usual=1: check for usual range
"""
- if type(value) in [types.StringType, types.FloatType, types.IntType]:
+ if type(value) in [types.StringType, types.FloatType, types.IntType,
+ types.UnicodeType]:
value = self.convert(value)
elif not isinstance(value, Distribution):
raise ValueError, "is1inrange() doesn't accept this value"
@@ -275,7 +276,7 @@
if not inrange:
break
except OverflowError, why:
- errors.append(str(why))
+ errors.append(unicode(why))
inrange = 0
if inrange:
errors.pop()
@@ -303,7 +304,7 @@
except ValueError, why:
pass
- if type(value) != types.StringType:
+ if not isinstance(value, basestring):
raise ValueError, \
"%s doesn't accept this value: %r" % (self.__class__, value)
@@ -390,7 +391,7 @@
if self.is1unknown(value):
return None
else:
- return str(value)
+ return unicode(value)
def __setattr__(self, name, value):
if name == 'maxlength':
@@ -463,9 +464,9 @@
if self.is1unknown(choice):
choice = self.unknown_yes_no[0]
elif type(choice) == types.TupleType:
- choice = str(choice[0]), choice[1]
+ choice = unicode(choice[0]), choice[1]
else:
- choice = str(choice), choice
+ choice = unicode(choice), choice
self.__dict__['choices'].append(choice[0])
self.__dict__['choicedict'][choice[0]] = choice[1]
self.__dict__['valuedict'][choice[1]] = choice[0]
More information about the Greater-commits
mailing list