summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Pipping <sebastian@pipping.org>2010-01-04 05:36:34 +0100
committerSebastian Pipping <sebastian@pipping.org>2010-01-04 05:36:34 +0100
commit836dea135b73c2b0e802888702c6b67c86f2bea4 (patch)
tree2dde4565291ae18112053c66210beb936a9ac2d1
parent4cfd62c88c855c90f56db1a60ef2e438b13ca3d6 (diff)
downloadlayman-836dea135b73c2b0e802888702c6b67c86f2bea4.tar.gz
layman-836dea135b73c2b0e802888702c6b67c86f2bea4.tar.bz2
layman-836dea135b73c2b0e802888702c6b67c86f2bea4.zip
Introduce equality and inequality tests
-rw-r--r--layman/overlay.py9
-rw-r--r--layman/overlays/cvs.py8
-rw-r--r--layman/overlays/overlay.py10
-rw-r--r--layman/overlays/tar.py10
4 files changed, 37 insertions, 0 deletions
diff --git a/layman/overlay.py b/layman/overlay.py
index ae19f28..643e652 100644
--- a/layman/overlay.py
+++ b/layman/overlay.py
@@ -84,6 +84,15 @@ class Overlays:
if os.path.exists(path):
self.read_file(path)
+ def __eq__(self, other):
+ for key in set(self.overlays.keys() + other.overlays.keys()):
+ if self.overlays[key] != other.overlays[key]:
+ return False
+ return True
+
+ def __ne__(self, other):
+ return not self.__eq__(other)
+
def read_file(self, path):
'''Read the overlay definition file.'''
diff --git a/layman/overlays/cvs.py b/layman/overlays/cvs.py
index a4ff74d..a9c4f0f 100644
--- a/layman/overlays/cvs.py
+++ b/layman/overlays/cvs.py
@@ -48,6 +48,14 @@ class CvsOverlay(Overlay):
else:
self.subpath = ''
+ def __eq__(self, other):
+ res = super(CvsOverlay, self).__eq__(other) \
+ and self.subpath == other.subpath
+ return res
+
+ def __ne__(self, other):
+ return not self.__eq__(other)
+
def add(self, base, quiet = False):
'''Add overlay.'''
diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index 8e1abc2..aa20f9d 100644
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -147,6 +147,16 @@ class Overlay(object):
else:
self.homepage = None
+ def __eq__(self, other):
+ for i in ('description', 'homepage', 'name', 'owner_email',
+ 'owner_name', 'priority', 'src', 'status'):
+ if getattr(self, i) != getattr(other, i):
+ return False
+ return True
+
+ def __ne__(self, other):
+ return not self.__eq__(other)
+
def set_priority(self, priority):
'''Set the priority of this overlay.'''
diff --git a/layman/overlays/tar.py b/layman/overlays/tar.py
index 2ef69af..d65befc 100644
--- a/layman/overlays/tar.py
+++ b/layman/overlays/tar.py
@@ -88,6 +88,16 @@ class TarOverlay(Overlay):
else:
self.category = ''
+ def __eq__(self, other):
+ res = super(TarOverlay, self).__eq__(other) \
+ and self.format == other.format \
+ and self.subpath == other.subpath \
+ and self.category == other.category
+ return res
+
+ def __ne__(self, other):
+ return not self.__eq__(other)
+
def add(self, base, quiet = False):
'''Add overlay.'''