本文整理汇总了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