More helpful class reprs

This commit is contained in:
Teknique 2023-07-23 12:47:31 -07:00
parent d9d03885d9
commit be2b3ec1e8
2 changed files with 10 additions and 0 deletions

View File

@ -13,6 +13,10 @@ class VeilidAPIError(Exception):
def __init__(self, *args, **kwargs):
super().__init__(self.label, *args, **kwargs)
def __str__(self) -> str:
args = [('label', self.label)] + sorted(vars(self).items())
return " ".join(f"{key}={value!r}" for (key, value) in args)
@classmethod
def from_json(cls, json: dict) -> Self:
kind = json["kind"]

View File

@ -351,6 +351,9 @@ class DHTRecordDescriptor:
self.owner_secret = owner_secret
self.schema = schema
def __repr__(self) -> str:
return f"<{self.__class__.__name__}(key={self.key!r})>"
@classmethod
def from_json(cls, j: dict) -> Self:
return cls(
@ -375,6 +378,9 @@ class ValueData:
self.data = data
self.writer = writer
def __repr__(self) -> str:
return f"<{self.__class__.__name__}(seq={self.seq!r}, data={self.data!r}, writer={self.writer!r})>"
def __lt__(self, other):
if other is None:
return True