aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincenzo Maffione <v.maffione@gmail.com>2017-03-19 10:22:36 +0100
committerVincenzo Maffione <v.maffione@gmail.com>2017-03-19 10:22:36 +0100
commit23b46068be8b698c55ab854eb5c2de2a3a14d453 (patch)
treead8278945bf1d5110d44b97183cad70367b7fbb1
parentd0e0210ba5c17fe1cd86af4ffadb8cc16fc88533 (diff)
downloadrumba-23b46068be8b698c55ab854eb5c2de2a3a14d453.tar.gz
rumba-23b46068be8b698c55ab854eb5c2de2a3a14d453.zip
class DIF and Node: add necessary methods for use in dict() and set()
-rw-r--r--rumba/model.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/rumba/model.py b/rumba/model.py
index 5c22185..45d0473 100644
--- a/rumba/model.py
+++ b/rumba/model.py
@@ -91,6 +91,15 @@ class DIF:
s = "DIF %s" % self.name
return s
+ def __hash__(self):
+ return hash(self.name)
+
+ def __eq__(self, other):
+ return other != None and self.name == other.name
+
+ def __neq__(self, other):
+ return not (self == other)
+
def add_member(self, node):
self.members.append(node)
@@ -199,6 +208,15 @@ class Node:
return s
+ def __hash__(self):
+ return hash(self.name)
+
+ def __eq__(self, other):
+ return other != None and self.name == other.name
+
+ def __neq__(self, other):
+ return not (self == other)
+
def add_dif(self, dif):
self.difs.append(dif)
dif.add_member(self)