Get the class substate. Args: path: The path to the substate. Returns: The class substate. Raises: ValueError: If the substate is not found.
(cls, path: Sequence[str] | str)
| 1088 | @classmethod |
| 1089 | @functools.lru_cache |
| 1090 | def get_class_substate(cls, path: Sequence[str] | str) -> type[BaseState]: |
| 1091 | """Get the class substate. |
| 1092 | |
| 1093 | Args: |
| 1094 | path: The path to the substate. |
| 1095 | |
| 1096 | Returns: |
| 1097 | The class substate. |
| 1098 | |
| 1099 | Raises: |
| 1100 | ValueError: If the substate is not found. |
| 1101 | """ |
| 1102 | if isinstance(path, str): |
| 1103 | path = tuple(path.split(".")) |
| 1104 | |
| 1105 | if len(path) == 0: |
| 1106 | return cls |
| 1107 | if path[0] == cls.get_name(): |
| 1108 | if len(path) == 1: |
| 1109 | return cls |
| 1110 | path = path[1:] |
| 1111 | for substate in cls.get_substates(): |
| 1112 | if path[0] == substate.get_name(): |
| 1113 | return substate.get_class_substate(path[1:]) |
| 1114 | msg = f"Invalid path: {path}" |
| 1115 | raise ValueError(msg) |
| 1116 | |
| 1117 | @classmethod |
| 1118 | def get_class_var(cls, path: Sequence[str]) -> Any: |