print larger packet fields

This commit is contained in:
əlemi 2022-04-27 13:33:03 +02:00
parent 7d05658fe9
commit 6bd4abafb1
No known key found for this signature in database
GPG key ID: BBCBFE5D7244634E

View file

@ -5,6 +5,8 @@ from typing import Tuple, Dict, Any
from .types import Type, VarInt, Context
MAX_FIELD_PRINT_SIZE = 255
class Packet:
__slots__ = 'id', 'definition', '_processed', '_proto', '_state'
@ -71,7 +73,7 @@ class Packet:
return json.dumps(obj, indent=2, default=str)
def __repr__(self) -> str:
trunc = lambda x : x if len(x) < 100 else "[blob]"
trunc = lambda x : x if len(x) < MAX_FIELD_PRINT_SIZE else "[blob]"
attrs = (f"{key}={trunc(repr(getattr(self, key, None)))}" for (key, t) in self.definition)
return f"{self.__class__.__name__}({self._proto}, {', '.join(attrs)})"