mirror of
https://github.com/gnuradio/gnuradio-companion.git
synced 2025-12-10 00:42:30 -06:00
grc: fixes in evaluated properties
This commit is contained in:
parent
e5bee3d4d5
commit
45d5f5efb7
@ -66,8 +66,9 @@ class Evaluated(object):
|
||||
def __set__(self, instance, value):
|
||||
attribs = instance.__dict__
|
||||
value = value or self.default
|
||||
if isinstance(value, six.text_type) and value.startswith('${') and value.endswith('}'):
|
||||
if isinstance(value, six.string_types) and value.startswith('${') and value.endswith('}'):
|
||||
attribs[self.name_raw] = value[2:-1].strip()
|
||||
attribs.pop(self.name, None) # reset previous eval result
|
||||
else:
|
||||
attribs[self.name] = type(self.default)(value)
|
||||
|
||||
|
||||
@ -56,6 +56,8 @@ def test_evaled():
|
||||
assert a.foo == 11 and a.foo == 11
|
||||
assert a.called['foo'] == 2
|
||||
assert not a.errors
|
||||
a.foo = u'${ 10 + 2 }'
|
||||
assert a.foo == 12
|
||||
|
||||
|
||||
def test_evaled_with_default():
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user