[Greater-commits] r3704 - in branches/3.0.0-all-models/sciparam/SciParam: . UI

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Jul 26 14:58:09 CEST 2011


Author: aheinecke
Date: 2011-07-26 14:58:08 +0200 (Tue, 26 Jul 2011)
New Revision: 3704

Modified:
   branches/3.0.0-all-models/sciparam/SciParam/
   branches/3.0.0-all-models/sciparam/SciParam/UI/dialog.py
   branches/3.0.0-all-models/sciparam/SciParam/UI/notebook.py
   branches/3.0.0-all-models/sciparam/SciParam/distribution.py
   branches/3.0.0-all-models/sciparam/SciParam/parameter.py
Log:
Merged revisions 3639 via svnmerge from 
svn+ssh://wald.intevation.org/greater/trunk/GREAT-ER/SciParam

........
  r3639 | aheinecke | 2011-07-22 12:04:57 +0200 (Fri, 22 Jul 2011) | 2 lines
  
  Make sciparam work with unicode
........



Property changes on: branches/3.0.0-all-models/sciparam/SciParam
___________________________________________________________________
Name: svnmerge-integrated
   - /trunk/GREAT-ER/SciParam:1-216,340,3638
   + /trunk/GREAT-ER/SciParam:1-216,340,3638-3639

Modified: branches/3.0.0-all-models/sciparam/SciParam/UI/dialog.py
===================================================================
--- branches/3.0.0-all-models/sciparam/SciParam/UI/dialog.py	2011-07-26 12:55:32 UTC (rev 3703)
+++ branches/3.0.0-all-models/sciparam/SciParam/UI/dialog.py	2011-07-26 12:58:08 UTC (rev 3704)
@@ -102,7 +102,7 @@
 
         for par in parameter:
             if 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])):
                 length_list.append(len(par[1]))
                 for grouppar in par[1]:

Modified: branches/3.0.0-all-models/sciparam/SciParam/UI/notebook.py
===================================================================
--- branches/3.0.0-all-models/sciparam/SciParam/UI/notebook.py	2011-07-26 12:55:32 UTC (rev 3703)
+++ branches/3.0.0-all-models/sciparam/SciParam/UI/notebook.py	2011-07-26 12:58:08 UTC (rev 3704)
@@ -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: branches/3.0.0-all-models/sciparam/SciParam/distribution.py
===================================================================
--- branches/3.0.0-all-models/sciparam/SciParam/distribution.py	2011-07-26 12:55:32 UTC (rev 3703)
+++ branches/3.0.0-all-models/sciparam/SciParam/distribution.py	2011-07-26 12:58:08 UTC (rev 3704)
@@ -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: branches/3.0.0-all-models/sciparam/SciParam/parameter.py
===================================================================
--- branches/3.0.0-all-models/sciparam/SciParam/parameter.py	2011-07-26 12:55:32 UTC (rev 3703)
+++ branches/3.0.0-all-models/sciparam/SciParam/parameter.py	2011-07-26 12:58:08 UTC (rev 3704)
@@ -150,7 +150,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.
@@ -245,7 +245,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
@@ -305,7 +305,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"
@@ -323,7 +324,7 @@
                     if not inrange:
                         break
             except OverflowError, why:
-                errors.append(str(why))
+                errors.append(unicode(why))
                 inrange = 0
         if inrange:
             errors.pop()
@@ -351,7 +352,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)
 
@@ -438,7 +439,7 @@
         if self.is1unknown(value):
             return None
         else:
-            return str(value)
+            return unicode(value)
 
     def __setattr__(self, name, value):
         if name == 'maxlength':
@@ -542,9 +543,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