Loosen string type checking a bit; let asUnicode throw errors if it
needs to.
This commit is contained in:
parent
c719ad4355
commit
b4e722f07b
@ -326,26 +326,12 @@ class SimpleParameter(Parameter):
|
|||||||
'int': int,
|
'int': int,
|
||||||
'float': float,
|
'float': float,
|
||||||
'bool': bool,
|
'bool': bool,
|
||||||
'str': self._interpStr,
|
'str': asUnicode,
|
||||||
'color': self._interpColor,
|
'color': self._interpColor,
|
||||||
'colormap': self._interpColormap,
|
'colormap': self._interpColormap,
|
||||||
}[self.opts['type']]
|
}[self.opts['type']]
|
||||||
return fn(v)
|
return fn(v)
|
||||||
|
|
||||||
def _interpStr(self, v):
|
|
||||||
isQString = hasattr(QtCore, 'QString') and isinstance(v, QtCore.QString)
|
|
||||||
if sys.version[0] == '2':
|
|
||||||
if isQString:
|
|
||||||
v = unicode(v)
|
|
||||||
elif not isinstance(v, basestring):
|
|
||||||
raise TypeError("Cannot set str parmeter from object %r" % v)
|
|
||||||
else:
|
|
||||||
if isQString:
|
|
||||||
v = str(v)
|
|
||||||
elif not isinstance(v, str):
|
|
||||||
raise TypeError("Cannot set str parmeter from object %r" % v)
|
|
||||||
return v
|
|
||||||
|
|
||||||
def _interpColor(self, v):
|
def _interpColor(self, v):
|
||||||
return fn.mkColor(v)
|
return fn.mkColor(v)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user