node_base.py 文件源码

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

项目:Sverchok 作者: Sverchok 项目源码 文件源码
def stateful(cls):
    """
    class decorator for creating stateful class
    """
    func = cls()
    get_signature(func)
    module_name = func.__module__.split(".")[-2]
    props = {}
    for name, prop in getattr(cls, 'properties', {}).items():
        if isinstance(prop, SvRxBaseTypeP):
            props[name] = prop.get_prop()
        else:
            props[name] = prop

    props.update(func.properties)

    class InnerStateful(cls, Stateful):
        category = module_name
        inputs_template = func.inputs_template.copy()
        outputs_template = func.outputs_template.copy()
        properties = props.copy()
        parameters = func.parameters.copy()
        returns = func.returns.copy()

    func_new = InnerStateful()
    class_factory(func_new)
    InnerStateful.node_cls = func_new.cls

    NodeStateful.add_cls(cls.bl_idname, InnerStateful)
    return InnerStateful
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号