MCPcopy
hub / github.com/google/earthengine-api / _InitializeUnboundMethods

Function _InitializeUnboundMethods

python/ee/__init__.py:426–458  ·  view source on GitHub ↗

Initializes the unbounded functions.

()

Source from the content-addressed store, hash-verified

424
425
426def _InitializeUnboundMethods() -> None:
427 """Initializes the unbounded functions."""
428 # Sort the items by length, so parents get created before children.
429 items = sorted(
430 ApiFunction.unboundFunctions().items(), key=lambda x: len(x[0]))
431
432 for name, func in items:
433 signature = func.getSignature()
434 if signature.get('hidden', False):
435 continue
436
437 # Create nested objects as needed.
438 name_parts = name.split('.')
439 target = Algorithms
440 while len(name_parts) > 1:
441 first = name_parts[0]
442 # Set the attribute if it doesn't already exist.
443 try:
444 getattr(target, first)
445 except AttributeError:
446 setattr(target, first, _AlgorithmsContainer())
447
448 target = getattr(target, first)
449 name_parts = name_parts[1:]
450
451 # Attach the function.
452 # We need a copy of the function to attach properties.
453 def GenerateFunction(f):
454 return lambda *args, **kwargs: f.call(*args, **kwargs) # pylint: disable=unnecessary-lambda
455 bound = GenerateFunction(func)
456 bound.signature = signature
457 bound.__doc__ = str(func)
458 setattr(target, name_parts[0], bound)
459
460
461def _InitializeGeneratedClasses() -> None:

Callers 1

InitializeFunction · 0.85

Calls 6

GenerateFunctionFunction · 0.85
unboundFunctionsMethod · 0.80
splitMethod · 0.80
getSignatureMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected