From c840935588fefda1cef85a3586b58d077b3d22f4 Mon Sep 17 00:00:00 2001 From: Markus Zolliker Date: Mon, 2 Mar 2020 11:30:29 +0100 Subject: [PATCH] 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 Reviewed-by: Markus Zolliker --- secop/params.py | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/secop/params.py b/secop/params.py index 4bd9541..f32068d 100644 --- a/secop/params.py +++ b/secop/params.py @@ -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(