aboutsummaryrefslogtreecommitdiff
path: root/discord/asset.py
diff options
context:
space:
mode:
authorRapptz <[email protected]>2019-04-13 17:21:15 -0400
committerRapptz <[email protected]>2019-04-13 17:22:25 -0400
commit7c091282cec1202614df100e4ea026b621b87d3d (patch)
treed9124e02996e44fbed07e725772e305715201085 /discord/asset.py
parentBool fix in TextChannel.purge documentation. (diff)
downloaddiscord.py-7c091282cec1202614df100e4ea026b621b87d3d.tar.xz
discord.py-7c091282cec1202614df100e4ea026b621b87d3d.zip
Add equality comparisons between two assets and hashing an asset.
Diffstat (limited to 'discord/asset.py')
-rw-r--r--discord/asset.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/discord/asset.py b/discord/asset.py
index 971a07c3..ee92d48b 100644
--- a/discord/asset.py
+++ b/discord/asset.py
@@ -48,6 +48,18 @@ class Asset:
.. describe:: bool(x)
Checks if the Asset has a URL.
+
+ .. describe:: x == y
+
+ Checks if the asset is equal to another asset.
+
+ .. describe:: x != y
+
+ Checks if the asset is not equal to another asset.
+
+ .. describe:: hash(x)
+
+ Returns the hash of the asset.
"""
__slots__ = ('_state', '_url')
@@ -109,6 +121,15 @@ class Asset:
def __repr__(self):
return '<Asset url={0._url!r}>'.format(self)
+ def __eq__(self, other):
+ return isinstance(other, Asset) and self._url == other._url
+
+ def __ne__(self, other):
+ return not self.__eq__(other)
+
+ def __hash__(self):
+ return hash(self._url)
+
async def save(self, fp, *, seek_begin=True):
"""|coro|