diff options
author | Vincenzo Maffione <v.maffione@gmail.com> | 2017-03-19 10:22:36 +0100 |
---|---|---|
committer | Vincenzo Maffione <v.maffione@gmail.com> | 2017-03-19 10:22:36 +0100 |
commit | 23b46068be8b698c55ab854eb5c2de2a3a14d453 (patch) | |
tree | ad8278945bf1d5110d44b97183cad70367b7fbb1 | |
parent | d0e0210ba5c17fe1cd86af4ffadb8cc16fc88533 (diff) | |
download | rumba-23b46068be8b698c55ab854eb5c2de2a3a14d453.tar.gz rumba-23b46068be8b698c55ab854eb5c2de2a3a14d453.zip |
class DIF and Node: add necessary methods for use in dict() and set()
-rw-r--r-- | rumba/model.py | 18 |
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) |