properties.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:core-framework 作者: RedhawkSDR 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号