clean up Parameter/Command.for_export
Change-Id: Ib90da24ed2be0ac32dcd3ea1c692fec9f2bd11bc Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/22566 Tested-by: JenkinsCodeReview <bjoern_pedersen@frm2.tum.de> Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
This commit is contained in:
@ -63,15 +63,8 @@ class Accessible(HasProperties, CountedObj):
|
|||||||
return type(self)(**props)
|
return type(self)(**props)
|
||||||
|
|
||||||
def for_export(self):
|
def for_export(self):
|
||||||
# used for serialisation only
|
"""prepare for serialisation"""
|
||||||
# some specials:
|
return self.exportProperties()
|
||||||
# - datatype needs a special serialisation
|
|
||||||
# - readonly is mandatory for serialisation, but not for declaration in classes
|
|
||||||
r = self.exportProperties()
|
|
||||||
if isinstance(self, Parameter):
|
|
||||||
if 'readonly' not in r:
|
|
||||||
r['readonly'] = self.__class__.properties['readonly'].default
|
|
||||||
return r
|
|
||||||
|
|
||||||
|
|
||||||
class Parameter(Accessible):
|
class Parameter(Accessible):
|
||||||
@ -181,6 +174,16 @@ class Parameter(Accessible):
|
|||||||
super().checkProperties()
|
super().checkProperties()
|
||||||
self.datatype.checkProperties()
|
self.datatype.checkProperties()
|
||||||
|
|
||||||
|
def for_export(self):
|
||||||
|
"""prepare for serialisation
|
||||||
|
|
||||||
|
readonly is mandatory for serialisation, but not for declaration in classes
|
||||||
|
"""
|
||||||
|
r = super().for_export()
|
||||||
|
if 'readonly' not in r:
|
||||||
|
r['readonly'] = self.__class__.properties['readonly'].default
|
||||||
|
return r
|
||||||
|
|
||||||
|
|
||||||
class UnusedClass:
|
class UnusedClass:
|
||||||
# do not derive anything from this!
|
# do not derive anything from this!
|
||||||
@ -300,20 +303,6 @@ class Command(Accessible):
|
|||||||
def result(self):
|
def result(self):
|
||||||
return self.datatype.result
|
return self.datatype.result
|
||||||
|
|
||||||
def for_export(self):
|
|
||||||
# used for serialisation only
|
|
||||||
# some specials:
|
|
||||||
# - datatype needs a special serialisation
|
|
||||||
# - readonly is mandatory for serialisation, but not for declaration in classes
|
|
||||||
r = self.exportProperties()
|
|
||||||
# if isinstance(self, Parameter):
|
|
||||||
# if 'readonly' not in r:
|
|
||||||
# r['readonly'] = self.__class__.properties['readonly'].default
|
|
||||||
# if 'datatype' in r:
|
|
||||||
# _d = r['datatype']
|
|
||||||
# print(formatExtendedStack()) # for debug
|
|
||||||
return r
|
|
||||||
|
|
||||||
|
|
||||||
# list of predefined accessibles with their type
|
# list of predefined accessibles with their type
|
||||||
PREDEFINED_ACCESSIBLES = dict(
|
PREDEFINED_ACCESSIBLES = dict(
|
||||||
|
Reference in New Issue
Block a user