cli.py 文件源码

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

项目:intel-manager-for-lustre 作者: intel-hpdd 项目源码 文件源码
def raw_result(wrapped):
    """
    Decorator for functions whose output should not be JSON-serialized.
    """
    def wrapper(*args, **kwargs):
        result = wrapped(*args, **kwargs)
        return {'raw_result': result}

    # These contortions are necessary to retain compatibility with
    # argparse's ability to generate CLI options by signature inspection.
    import functools
    wrapped_signature = inspect.getargspec(wrapped)
    formatted_args = inspect.formatargspec(*wrapped_signature)
    compat_name = "_%s" % wrapped.func_name
    compat_def = 'lambda %s: %s%s' % (formatted_args.lstrip('(').rstrip(')'),
                                      compat_name, formatted_args)
    compat_fn = eval(compat_def, {compat_name: wrapper})
    return functools.wraps(wrapped)(compat_fn)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号