All data classes now support !=, == and str(obj).

This commit is contained in:
Rapptz
2015-12-13 22:53:48 -05:00
parent ab46afee1d
commit 9137d92f67
8 changed files with 149 additions and 17 deletions

View File

@ -37,6 +37,16 @@ def create_permission_masks(cls):
class Permissions(object):
"""Wraps up the Discord permission value.
Supported operations:
+-----------+------------------------------------------+
| Operation | Description |
+===========+==========================================+
| x == y | Checks if two permissions are equal. |
+-----------+------------------------------------------+
| x != y | Checks if two permissions are not equal. |
+-----------+------------------------------------------+
Class attributes:
.. attribute:: NONE
@ -80,6 +90,12 @@ class Permissions(object):
def __init__(self, permissions=0, **kwargs):
self.value = permissions
def __eq__(self, other):
return isinstance(other, Permissions) and self.value == other.value
def __ne__(self, other):
return not self.__eq__(other)
@classmethod
def none(cls):
"""A factory method that creates a :class:`Permission` with all