More helpful class reprs
This commit is contained in:
parent
d9d03885d9
commit
be2b3ec1e8
@ -13,6 +13,10 @@ class VeilidAPIError(Exception):
|
|||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(self.label, *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
|
@classmethod
|
||||||
def from_json(cls, json: dict) -> Self:
|
def from_json(cls, json: dict) -> Self:
|
||||||
kind = json["kind"]
|
kind = json["kind"]
|
||||||
|
@ -351,6 +351,9 @@ class DHTRecordDescriptor:
|
|||||||
self.owner_secret = owner_secret
|
self.owner_secret = owner_secret
|
||||||
self.schema = schema
|
self.schema = schema
|
||||||
|
|
||||||
|
def __repr__(self) -> str:
|
||||||
|
return f"<{self.__class__.__name__}(key={self.key!r})>"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_json(cls, j: dict) -> Self:
|
def from_json(cls, j: dict) -> Self:
|
||||||
return cls(
|
return cls(
|
||||||
@ -375,6 +378,9 @@ class ValueData:
|
|||||||
self.data = data
|
self.data = data
|
||||||
self.writer = writer
|
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):
|
def __lt__(self, other):
|
||||||
if other is None:
|
if other is None:
|
||||||
return True
|
return True
|
||||||
|
Loading…
Reference in New Issue
Block a user