allow Override also for Commands

modified cryo.py for using Override correctly, here the description of the stop command is overridden

Change-Id: I060a2802226239f3af3dc1e573b7148d863b938c
Reviewed-on: https://forge.frm2.tum.de/review/19607
Tested-by: JenkinsCodeReview <bjoern_pedersen@frm2.tum.de>
Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
This commit is contained in:
2018-12-13 11:47:08 +01:00
committed by Enrico Faulhaber
parent 8c85a775a1
commit 0a71c97f69
2 changed files with 11 additions and 13 deletions

View File

@ -136,9 +136,9 @@ class Override(CountedObj):
return '%s_%d(%s)' % (self.__class__.__name__, self.ctr, ', '.join(
['%s=%r' % (k, v) for k, v in sorted(self.kwds.items())]))
def apply(self, paramobj):
if isinstance(paramobj, Parameter):
props = paramobj.__dict__.copy()
def apply(self, obj):
if isinstance(obj, CountedObj):
props = obj.__dict__.copy()
for k, v in self.kwds.items():
if k in props:
props[k] = v
@ -147,11 +147,11 @@ class Override(CountedObj):
"Can not apply Override(%s=%r) to %r: non-existing property!" %
(k, v, props))
props['ctr'] = self.ctr
return Parameter(**props)
return type(obj)(**props)
else:
raise ProgrammingError(
"Overrides can only be applied to Parameter's, %r is none!" %
paramobj)
obj)
class Command(CountedObj):