当前位置: 首页>>代码示例>>Python>>正文


Python Function._registerPromoter方法代码示例

本文整理汇总了Python中function.Function._registerPromoter方法的典型用法代码示例。如果您正苦于以下问题:Python Function._registerPromoter方法的具体用法?Python Function._registerPromoter怎么用?Python Function._registerPromoter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在function.Function的用法示例。


在下文中一共展示了Function._registerPromoter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: promote

# 需要导入模块: from function import Function [as 别名]
# 或者: from function.Function import _registerPromoter [as 别名]
                    # Can't cast a primitive.
                    shouldUseConstructor = True
                elif args[0].func != ctor:
                    # We haven't already called the constructor on this object.
                    shouldUseConstructor = True

        # Apply our decision.
        if shouldUseConstructor:
            # Call ctor manually to avoid having promote() called on the output.
            ComputedObject.__init__(self, ctor, ctor.promoteArgs(ctor.nameArgs(args)))
        else:
            # Just cast and hope for the best.
            if not onlyOneArg:
                # We don't know what to do with multiple args.
                raise EEException("Too many arguments for ee.%s(): %s" % (name, args))
            elif firstArgIsPrimitive:
                # Can't cast a primitive.
                raise EEException("Invalid argument for ee.%s(): %s.  Must be a ComputedObject." % (name, args))
            else:
                result = args[0]
            ComputedObject.__init__(self, result.func, result.args, result.varName)

    properties = {"__init__": init, "name": lambda self: name}
    new_class = type(str(name), (ComputedObject,), properties)
    ApiFunction.importApi(new_class, name, name)
    return new_class


# Set up type promotion rules as soon the package is loaded.
Function._registerPromoter(_Promote)  # pylint: disable=protected-access
开发者ID:bevingtona,项目名称:earthengine-api,代码行数:32,代码来源:__init__.py


注:本文中的function.Function._registerPromoter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。