[Piglit] [PATCH 24/34] registry/gl.py: add hash methods for classes that need to be hashed
Dylan Baker
baker.dylan.c at gmail.com
Fri Feb 20 18:18:11 PST 2015
Adds __hash__ methods to a few classes. These aren't particularly
unique, but they're good enough for our uses.
Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
registry/gl.py | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/registry/gl.py b/registry/gl.py
index 288a4fc..f85e393 100644
--- a/registry/gl.py
+++ b/registry/gl.py
@@ -633,6 +633,10 @@ class Requirement(object):
_log_debug('created {0}'.format(self))
+ def __hash__(self):
+ return hash('__Requirement_class_{}_{}_'.format(
+ self.provider, self.provided))
+
def __eq__(self, other):
if self.provider != other.provider:
return False
@@ -780,6 +784,9 @@ class Command(object):
'alias={self.alias!r}, '
'prototype={self.c_prototype!r})').format(self=self))
+ def __hash__(self):
+ return hash('__Command_class_{}_'.format(self.name))
+
def __eq__(self, other):
return self.name == other.name
@@ -860,6 +867,9 @@ class CommandAliasSet(ImmutableOrderedKeyedSet):
templ = '{self.__class__.__name__}({self.name!r})'
return templ.format(self=self)
+ def __hash__(self):
+ return hash(repr(self))
+
@property
def name(self):
return self.primary_command.name
--
2.3.0
More information about the Piglit
mailing list