__init__.py 文件源码

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

项目:azure-cli 作者: Azure 项目源码 文件源码
def get_op_handler(operation):
    """ Import and load the operation handler """
    # Patch the unversioned sdk path to include the appropriate API version for the
    # resource type in question.
    from azure.cli.core._profile import CLOUD
    import types

    for rt in ResourceType:
        if operation.startswith(rt.import_prefix + ".operations."):
            subs = operation[len(rt.import_prefix + ".operations."):]
            operation_group = subs[:subs.index('_operations')]
            operation = operation.replace(
                rt.import_prefix,
                get_versioned_sdk_path(CLOUD.profile, rt, operation_group=operation_group))
        elif operation.startswith(rt.import_prefix):
            operation = operation.replace(rt.import_prefix,
                                          get_versioned_sdk_path(CLOUD.profile, rt))
    try:
        mod_to_import, attr_path = operation.split('#')
        op = import_module(mod_to_import)
        for part in attr_path.split('.'):
            op = getattr(op, part)
        if isinstance(op, types.FunctionType):
            return op
        return six.get_method_function(op)
    except (ValueError, AttributeError):
        raise ValueError("The operation '{}' is invalid.".format(operation))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号