base.py 文件源码

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

项目:MDT 作者: cbclab 项目源码 文件源码
def method_binding_meta(template, *bases):
    """Adds all bound functions from the ComponentTemplate to the class being constructed.

     This returns a metaclass similar to the with_metaclass of the six library.

     Args:
         template (ComponentTemplate): the component config with the bound_methods attribute which we will all add
            to the attributes of the to creating class.
     """
    class ApplyMethodBinding(type):
        def __new__(mcs, name, bases, attributes):
            attributes.update(template.bound_methods)
            return super(ApplyMethodBinding, mcs).__new__(mcs, name, bases, attributes)

    return with_metaclass(ApplyMethodBinding, *bases)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号