From: Christian Heller Date: Tue, 3 Dec 2024 03:03:33 +0000 (+0100) Subject: To fix sync, add comparison and string representation to Hash class. X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/%7B%7B%20web_path%20%7D%7D/static/bar%20baz.html?a=commitdiff_plain;h=b4acf9ccb0fcd20da4b9205f8d66b2169cd7edd9;p=ytplom To fix sync, add comparison and string representation to Hash class. --- diff --git a/src/ytplom/db.py b/src/ytplom/db.py index 5387eca..30d84fc 100644 --- a/src/ytplom/db.py +++ b/src/ytplom/db.py @@ -31,6 +31,14 @@ class Hash: def __init__(self, as_bytes: bytes) -> None: self.bytes = as_bytes + def __eq__(self, other): + if not isinstance(other, Hash): + return False + return self.bytes == other.bytes + + def __str__(self): + return self.b64 + @classmethod def from_file(cls, path: Path) -> Self: """Hash-digest file at path, instantiate with hash's bytes."""