Skip to content

Commit

Permalink
Meaningful __repr__ for objects (#95)
Browse files Browse the repository at this point in the history
* Meaningful __repr__ for objects

* Bump version to 4.5.0
  • Loading branch information
psrok1 authored Jul 21, 2023
1 parent 5a44505 commit 1a057be
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mwdblib/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "4.4.0"
__version__ = "4.5.0"
6 changes: 6 additions & 0 deletions mwdblib/blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,9 @@ def last_seen(self) -> "datetime.datetime":
if "last_seen" not in self.data:
self._load()
return datetime.datetime.fromisoformat(self.data["last_seen"])

def __repr__(self) -> str:
return (
f"MWDBBlob(id={repr(self.id)}, name={repr(self.blob_name)}, "
f"type={repr(self.blob_type)})"
)
3 changes: 3 additions & 0 deletions mwdblib/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,6 @@ def delete(self) -> None:
Deletes this comment
"""
self.api.delete("object/{}/comment/{}".format(self.parent.id, self.id))

def __repr__(self) -> str:
return f"MWDBComment(id={repr(self.id)}, author={repr(self.author)})"
6 changes: 6 additions & 0 deletions mwdblib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,9 @@ def cfg(self) -> Dict[str, Any]:
.. seealso:: :py:attr:`config_dict`
"""
return self.config

def __repr__(self) -> str:
return (
f"MWDBConfig(id={repr(self.id)}, family={repr(self.family)}, "
f"type={repr(self.type)})"
)
6 changes: 6 additions & 0 deletions mwdblib/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1053,3 +1053,9 @@ def upload_blob(
)
result = self.api.post("blob", json=params)
return MWDBBlob(self.api, result)

def __repr__(self) -> str:
return (
f"MWDB(api_url={repr(self.api.options.api_url)}, "
f"username={repr(self.api.logged_user)})"
)
3 changes: 3 additions & 0 deletions mwdblib/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,6 @@ def download_legacy(self) -> bytes:
"/"
)[-1]
return cast(bytes, self.api.get("download/{}".format(token), raw=True))

def __repr__(self) -> str:
return f"MWDBFile(sha256={repr(self.id)}, name={repr(self.file_name)})"
3 changes: 3 additions & 0 deletions mwdblib/karton.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ def arguments(self) -> Dict[str, Any]:
@property
def processing_in(self) -> Dict[str, Any]:
return cast(Dict[str, Any], self.data["processing_in"])

def __repr__(self) -> str:
return f"MWDBKartonAnalysis(id={repr(self.id)})"

0 comments on commit 1a057be

Please sign in to comment.