| 31 | |
| 32 | @dataclass |
| 33 | class Question(serializable.SerializableDataclass): |
| 34 | HEADER: ClassVar[struct.Struct] = struct.Struct("!HH") |
| 35 | |
| 36 | name: str |
| 37 | type: int |
| 38 | class_: int |
| 39 | |
| 40 | def __str__(self) -> str: |
| 41 | return self.name |
| 42 | |
| 43 | def to_json(self) -> dict: |
| 44 | """ |
| 45 | Converts the question into json for mitmweb. |
| 46 | Sync with web/src/flow.ts. |
| 47 | """ |
| 48 | return { |
| 49 | "name": self.name, |
| 50 | "type": types.to_str(self.type), |
| 51 | "class": classes.to_str(self.class_), |
| 52 | } |
| 53 | |
| 54 | @classmethod |
| 55 | def from_json(cls, data: dict[str, str]) -> Self: |
| 56 | return cls( |
| 57 | name=data["name"], |
| 58 | type=types.from_str(data["type"]), |
| 59 | class_=classes.from_str(data["class"]), |
| 60 | ) |
| 61 | |
| 62 | |
| 63 | @dataclass |
no outgoing calls
no test coverage detected
searching dependent graphs…