mirror of
https://gitlab.com/veilid/veilid.git
synced 2025-05-02 22:54:51 -04:00
More helpful class reprs
This commit is contained in:
parent
d9d03885d9
commit
be2b3ec1e8
2 changed files with 10 additions and 0 deletions
|
@ -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"]
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue