allow to remove accessibles
removing an inherited command or parameter can now be indicated with an attribute set to None Change-Id: I9645c58e2589c878b62dcebe7a80f479a2b65339
This commit is contained in:
parent
6c4bb78f97
commit
039ece9549
@ -30,7 +30,7 @@ from secop.datatypes import ArrayOf, BoolType, EnumType, FloatRange, \
|
|||||||
IntRange, StatusType, StringType, TextType, TupleOf, get_datatype
|
IntRange, StatusType, StringType, TextType, TupleOf, get_datatype
|
||||||
from secop.errors import BadValueError, ConfigError, InternalError, \
|
from secop.errors import BadValueError, ConfigError, InternalError, \
|
||||||
ProgrammingError, SECoPError, SilentError, secop_error
|
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.lib.enum import Enum
|
||||||
from secop.params import Accessible, Command, Parameter
|
from secop.params import Accessible, Command, Parameter
|
||||||
from secop.poller import BasicPoller, Poller
|
from secop.poller import BasicPoller, Poller
|
||||||
@ -56,13 +56,19 @@ class HasAccessibles(HasProperties):
|
|||||||
for base in reversed(cls.__bases__):
|
for base in reversed(cls.__bases__):
|
||||||
accessibles.update(getattr(base, 'accessibles', {}))
|
accessibles.update(getattr(base, 'accessibles', {}))
|
||||||
newaccessibles = {k: v for k, v in cls.__dict__.items() if isinstance(v, Accessible)}
|
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)
|
value = getattr(cls, aname, None)
|
||||||
if not isinstance(value, Accessible): # else override is already done in __set_name__
|
if not isinstance(value, Accessible): # else override is already done in __set_name__
|
||||||
anew = aobj.override(value)
|
if value is None:
|
||||||
newaccessibles[aname] = anew
|
accessibles.pop(aname)
|
||||||
setattr(cls, aname, anew)
|
else:
|
||||||
anew.__set_name__(cls, aname)
|
# 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 = {}
|
ordered = {}
|
||||||
for aname in cls.__dict__.get('paramOrder', ()):
|
for aname in cls.__dict__.get('paramOrder', ()):
|
||||||
if aname in accessibles:
|
if aname in accessibles:
|
||||||
@ -221,7 +227,7 @@ class Module(HasAccessibles):
|
|||||||
default='user', extname='visibility')
|
default='user', extname='visibility')
|
||||||
implementation = Property('internal name of the implementation class of the module', StringType(),
|
implementation = Property('internal name of the implementation class of the module', StringType(),
|
||||||
extname='implementation')
|
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')
|
extname='interface_classes')
|
||||||
|
|
||||||
# properties, parameters and commands are auto-merged upon subclassing
|
# properties, parameters and commands are auto-merged upon subclassing
|
||||||
|
Loading…
x
Reference in New Issue
Block a user