util.py 文件源码

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

项目:RPoint 作者: george17-meet 项目源码 文件源码
def monkeypatch_method(cls):
    """A function decorator to monkey-patch a method of the same name on the
    given class.
    """

    def wrapper(func):
        orig = getattr(cls, func.__name__, None)
        if orig and not hasattr(orig, '_orig'):  # Already patched
            setattr(func, '_orig', orig)
            setattr(cls, func.__name__, func)
        return func

    return wrapper


# The following classes are used to hack Distribution.command_options a bit
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号