Recorder¶
Bases: ABC
Source code in gamms/typing/recorder.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
|
add_component(name, obj)
abstractmethod
¶
Add a component to the recorder.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Name of the component. |
required |
obj
|
Type[_T]
|
Component object. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
If the component already exists. |
Source code in gamms/typing/recorder.py
component(struct)
abstractmethod
¶
Decorator to add a component to the recorder.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
struct
|
Dict[str, Type[_T]]
|
Dictionary with component name and type. |
required |
Returns:
Type | Description |
---|---|
Callable[[Type[_T]], Type[_T]]
|
Callable[[Type[_T]], Type[_T]]: Decorator function. |
Source code in gamms/typing/recorder.py
component_iter()
abstractmethod
¶
delete_component(name)
abstractmethod
¶
Delete the component from the name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Name of the component. |
required |
Raises:
Type | Description |
---|---|
KeyError
|
If the component is not found. |
get_component(name)
abstractmethod
¶
Get the component from the name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Name of the component. |
required |
Returns:
Type | Description |
---|---|
object
|
Type[_T]: Component object. |
Raises:
Type | Description |
---|---|
KeyError
|
If the component is not found. |
Source code in gamms/typing/recorder.py
is_component_registered(key)
abstractmethod
¶
Check if the component is registered. Key is (module_name, qualname)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key
|
Tuple[str, str]
|
Key to check. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if registered, False otherwise. |
Source code in gamms/typing/recorder.py
pause()
abstractmethod
¶
Pause the recording process. self.record()
should return false if paused. If not started or stopped, give warning.
play()
abstractmethod
¶
record()
abstractmethod
¶
Boolean to inform whether game is being recorded or not and ctx is alive
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if recording, False otherwise |
replay(path)
abstractmethod
¶
Checks validity of the file and output an iterator.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
Union[str, BinaryIO]
|
Path to the recording file. |
required |
Returns:
Name | Type | Description |
---|---|---|
Iterator |
Iterator[Dict[str, Any]]
|
Iterator to replay the recording. |
Raises:
Type | Description |
---|---|
RuntimeError
|
If replay is already in progress. |
FileNotFoundError
|
If the file does not exist. |
TypeError
|
If the path is not a string or file object. |
ValueError
|
If the file is not a valid recording file or if recording terminated unexpectedly. |
ValueError
|
If the version of the file is not supported. |
Source code in gamms/typing/recorder.py
start(path)
abstractmethod
¶
Start recording to the path. Raise error if file already exists Adds ".ggr" extension if not present.
If path is a file object, it will be used as the file handler.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
Union[str, BinaryIO]
|
Path to record the game. |
required |
Raises:
Type | Description |
---|---|
FileExistsError
|
If the file already exists. |
TypeError
|
If the path is not a string or file object. |
Source code in gamms/typing/recorder.py
stop()
abstractmethod
¶
Stop recording to the path and close the file handler.
Raises:
Type | Description |
---|---|
RuntimeError
|
If recording has not started. |
time()
abstractmethod
¶
Return record time if replaying. Else return the local time (time.time())
in nano seconds.
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
Time in nanoseconds. |
unregister_component(key)
abstractmethod
¶
Unregister the component. Key is (module_name, qualname)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key
|
Tuple[str, str]
|
Key to unregister. |
required |
Raises:
Type | Description |
---|---|
KeyError
|
If the component is not found. |
Source code in gamms/typing/recorder.py
write(opCode, data)
abstractmethod
¶
Write to record buffer if recording. If not recording raise error as it should not happen.
WARNING: This function should not be required to be called by the user in most cases.