| 162 | holds_packets = 0 |
| 163 | |
| 164 | def __init__(self, name, default, fmt="H"): |
| 165 | # type: (str, Any, str) -> None |
| 166 | if not isinstance(name, str): |
| 167 | raise ValueError("name should be a string") |
| 168 | self.name = name |
| 169 | if fmt[0] in "@=<>!": |
| 170 | self.fmt = fmt |
| 171 | else: |
| 172 | self.fmt = "!" + fmt |
| 173 | self.struct = struct.Struct(self.fmt) |
| 174 | self.default = self.any2i(None, default) |
| 175 | self.sz = struct.calcsize(self.fmt) # type: int |
| 176 | self.owners = [] # type: List[Type[Packet]] |
| 177 | |
| 178 | def register_owner(self, cls): |
| 179 | # type: (Type[Packet]) -> None |