Get the source code of a global object. If value is a function or class we render the actual source of value otherwise we assign value to key. Args: key: variable name to assign value to. value: value of the global variable. Returns:
(key: str, value: Any)
| 429 | |
| 430 | @staticmethod |
| 431 | def get_app_global_source(key: str, value: Any): |
| 432 | """Get the source code of a global object. |
| 433 | If value is a function or class we render the actual |
| 434 | source of value otherwise we assign value to key. |
| 435 | |
| 436 | Args: |
| 437 | key: variable name to assign value to. |
| 438 | value: value of the global variable. |
| 439 | |
| 440 | Returns: |
| 441 | The rendered app global code. |
| 442 | """ |
| 443 | if not isinstance(value, type) and not inspect.isfunction(value): |
| 444 | return f"{key} = {value!r}" |
| 445 | return inspect.getsource(value) |
| 446 | |
| 447 | def __enter__(self) -> Self: |
| 448 | """Contextmanager protocol for `start()`. |