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:
2020-03-02 11:30:29 +01:00
parent ed12e2ed93
commit c840935588

View File

@ -63,15 +63,8 @@ class Accessible(HasProperties, CountedObj):
return type(self)(**props)
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
return r
"""prepare for serialisation"""
return self.exportProperties()
class Parameter(Accessible):
@ -181,6 +174,16 @@ class Parameter(Accessible):
super().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:
# do not derive anything from this!
@ -300,20 +303,6 @@ class Command(Accessible):
def result(self):
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
PREDEFINED_ACCESSIBLES = dict(