Skip to content

Commit

Permalink
Bucket: add string representation and equality method (#1095)
Browse files Browse the repository at this point in the history
* add string representation as well as equality method

* add __hash__ method to be able to use a bucket object inside a set or a dictionary
  • Loading branch information
GreatBahram authored May 24, 2021
1 parent ec18f54 commit df3e895
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions minio/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,22 @@ def creation_date(self):
"""Get creation date."""
return self._creation_date

def __repr__(self):
return "{}({!r})".format(type(self).__name__, self.name)

def __str__(self):
return self.name

def __eq__(self, other):
if isinstance(other, Bucket):
return self.name == other.name
if isinstance(other, str):
return self.name == other
return NotImplemented

def __hash__(self):
return hash(self.name)


class ListAllMyBucketsResult:
"""LissBuckets API result."""
Expand Down

0 comments on commit df3e895

Please sign in to comment.