From 039ece9549039f4a4d782da9cedddb55df2c2693 Mon Sep 17 00:00:00 2001 From: Markus Zolliker Date: Tue, 8 Jun 2021 16:17:23 +0200 Subject: [PATCH] allow to remove accessibles removing an inherited command or parameter can now be indicated with an attribute set to None Change-Id: I9645c58e2589c878b62dcebe7a80f479a2b65339 --- secop/modules.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/secop/modules.py b/secop/modules.py index ed1df5d..c19ebb6 100644 --- a/secop/modules.py +++ b/secop/modules.py @@ -30,7 +30,7 @@ from secop.datatypes import ArrayOf, BoolType, EnumType, FloatRange, \ IntRange, StatusType, StringType, TextType, TupleOf, get_datatype from secop.errors import BadValueError, ConfigError, InternalError, \ ProgrammingError, SECoPError, SilentError, secop_error -from secop.lib import formatException, getGeneralConfig, mkthread +from secop.lib import formatException, mkthread from secop.lib.enum import Enum from secop.params import Accessible, Command, Parameter from secop.poller import BasicPoller, Poller @@ -56,13 +56,19 @@ class HasAccessibles(HasProperties): for base in reversed(cls.__bases__): accessibles.update(getattr(base, 'accessibles', {})) newaccessibles = {k: v for k, v in cls.__dict__.items() if isinstance(v, Accessible)} - for aname, aobj in accessibles.items(): + for aname, aobj in list(accessibles.items()): value = getattr(cls, aname, None) if not isinstance(value, Accessible): # else override is already done in __set_name__ - anew = aobj.override(value) - newaccessibles[aname] = anew - setattr(cls, aname, anew) - anew.__set_name__(cls, aname) + if value is None: + accessibles.pop(aname) + else: + # this is either a method overwriting a command + # or a value overwriting a property value or parameter default + anew = aobj.override(value) + newaccessibles[aname] = anew + setattr(cls, aname, anew) + anew.__set_name__(cls, aname) + ordered = {} for aname in cls.__dict__.get('paramOrder', ()): if aname in accessibles: @@ -221,7 +227,7 @@ class Module(HasAccessibles): default='user', extname='visibility') implementation = Property('internal name of the implementation class of the module', StringType(), extname='implementation') - interface_classes = Property('offical highest Interface-class of the module', ArrayOf(StringType()), + interface_classes = Property('offical highest interface-class of the module', ArrayOf(StringType()), extname='interface_classes') # properties, parameters and commands are auto-merged upon subclassing