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

Class String

python/ee/ee_string.py:15–257  ·  view source on GitHub ↗

An object to represent strings.

Source from the content-addressed store, hash-verified

13
14
15class String(computedobject.ComputedObject):
16 """An object to represent strings."""
17
18 _string: str | None
19
20 _initialized = False
21
22 # Tell pytype to not complain about dynamic attributes.
23 _HAS_DYNAMIC_ATTRIBUTES = True
24
25 def __init__(self, string: _arg_types.String):
26 """Construct a string wrapper.
27
28 This constructor accepts the following args:
29 1) A bare string.
30 2) A ComputedObject returning a string.
31
32 Args:
33 string: The string to wrap.
34 """
35 self.initialize()
36
37 if isinstance(string, str):
38 super().__init__(None, None)
39 self._string = string
40 elif isinstance(string, computedobject.ComputedObject):
41 if self.is_func_returning_same(string):
42 # If it's a call that's already returning a String, just cast.
43 super().__init__(string.func, string.args, string.varName)
44 else:
45 # Wrap some other ComputedObject.
46 super().__init__(
47 apifunction.ApiFunction(self.name()), {'input': string}
48 )
49 self._string = None
50 else:
51 raise ee_exception.EEException(
52 f'Invalid argument specified for ee.String(): {string}')
53
54 @classmethod
55 def initialize(cls) -> None:
56 """Imports API functions to this class."""
57 if not cls._initialized:
58 apifunction.ApiFunction.importApi(cls, cls.name(), cls.name())
59 cls._initialized = True
60
61 @classmethod
62 def reset(cls) -> None:
63 """Removes imported API functions from this class."""
64 apifunction.ApiFunction.clearApi(cls)
65 cls._initialized = False
66
67 @staticmethod
68 def name() -> str:
69 return 'String'
70
71 @_utils.accept_opt_prefix('opt_encoder')
72 def encode(self, encoder: Any = None) -> Any:

Callers 15

_PromoteFunction · 0.85
encodable.jsFile · 0.85
callbackWrapperFunction · 0.85
computedobject.jsFile · 0.85
serializer.jsFile · 0.85
makeRefFunction · 0.85
optimizeReferenceMethod · 0.85
stringOrNull_Function · 0.85
formatTileUrlFunction · 0.85
validateMethod · 0.85
apiclient.jsFile · 0.85
callbackWrapperFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected