def __init__(self,
id_,
structdef,
name=None,
mode="readwrite",
configurationkind=("configure","property"),
description=None,
fget=None,
fset=None,
fval=None):
"""Construct a property of type struct.
@param structdef the structure definition, which is any class with simple_property attributes
"""
# struct properties have been extended to support multiple kinds,
# similar to simple and simplesequence. For backwards compatibility,
# convert string values into tuples.
if isinstance(configurationkind, str):
configurationkind = (configurationkind,)
_property.__init__(self, id_, None, name, None, mode, "external", configurationkind, description, fget, fset, fval)
if type(structdef) is types.ClassType:
raise ValueError("structdef must be a new-style python class (i.e. inherits from object)")
self.structdef = structdef
self.fields = {} # Map field id's to attribute names
for name, attr in self.structdef.__dict__.items():
if type(attr) is simple_property:
self.fields[attr.id_] = (name, attr)
elif type(attr) is simpleseq_property:
self.fields[attr.id_] = (name, attr)
评论列表
文章目录