Associate a callable with a particular func. name. This is normally called by GenericFunction, but is also available by itself so that a non-Function construct can be associated with the :data:`.func` accessor (i.e. CAST, EXTRACT).
(
identifier: str, fn: Type[Function[Any]], package: str = "_default"
)
| 93 | |
| 94 | |
| 95 | def register_function( |
| 96 | identifier: str, fn: Type[Function[Any]], package: str = "_default" |
| 97 | ) -> None: |
| 98 | """Associate a callable with a particular func. name. |
| 99 | |
| 100 | This is normally called by GenericFunction, but is also |
| 101 | available by itself so that a non-Function construct |
| 102 | can be associated with the :data:`.func` accessor (i.e. |
| 103 | CAST, EXTRACT). |
| 104 | |
| 105 | """ |
| 106 | reg = _registry[package] |
| 107 | |
| 108 | identifier = str(identifier).lower() |
| 109 | |
| 110 | # Check if a function with the same identifier is registered. |
| 111 | if identifier in reg: |
| 112 | util.warn( |
| 113 | "The GenericFunction '{}' is already registered and " |
| 114 | "is going to be overridden.".format(identifier) |
| 115 | ) |
| 116 | reg[identifier] = fn |
| 117 | |
| 118 | |
| 119 | class FunctionElement( |
no test coverage detected