(data)
| 35 | |
| 36 | |
| 37 | def parse_action(data): |
| 38 | try: |
| 39 | jsonschema.validate(data, EXTRACT_SCHEMA) |
| 40 | |
| 41 | actions = {} |
| 42 | parameters = {} |
| 43 | status = data.get("STATUS", "continue") # Default value |
| 44 | |
| 45 | # Define actions |
| 46 | action_keys = ["POINT", "to", "PRESS", "TYPE"] |
| 47 | |
| 48 | # Extract actions |
| 49 | for key in action_keys: |
| 50 | if key in data: |
| 51 | actions[key] = data[key] |
| 52 | |
| 53 | # Extract global parameters |
| 54 | parameters["duration"] = data.get("duration", EXTRACT_SCHEMA["properties"]["duration"]["default"]) |
| 55 | |
| 56 | # Handle "to" parameter, if present |
| 57 | if "to" in data: |
| 58 | parameters["to"] = data["to"] |
| 59 | |
| 60 | return actions, parameters, status |
| 61 | |
| 62 | except Exception as e: |
| 63 | print('Error, JSON is NOT valid according to the schema.') |
| 64 | return None, None, None |
| 65 | |
| 66 | |
| 67 | # Use multiprocessing to speed up processing |
no outgoing calls
no test coverage detected