--- /dev/null
+#!/usr/bin/env python
+# vim: set ts=4 sts=4 sw=4 textwidth=80:
+
+"""
+Holds the PAR2Set CompareSet class
+
+This class is used in the detection of PAR2Sets, and is provided here
+to reduce the coupling between rarslave.py and the PAR2Set classes.
+
+You should create one of these, and then send it to any of the other PAR2Set
+classes' constructor.
+"""
+
+__author__ = "Ira W. Snyder (devel@irasnyder.com)"
+__copyright__ = "Copyright (c) 2008 Ira W. Snyder (devel@irasnyder.com)"
+__license__ = "GNU GPL v2 (or, at your option, any later version)"
+
+# CompareSet.py
+#
+# Copyright (C) 2008 Ira W. Snyder (devel@irasnyder.com)
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+from PAR2Set import utils, par2parser
+
+class CompareSet(object):
+
+ ############################################################################
+
+ def __init__(self, directory, parityFile):
+ self.directory = directory
+ self.parityFile = parityFile
+
+ self.baseName = utils.getBasename(parityFile)
+ self.similarlyNamedFiles = utils.findFileNameMatches(directory, self.baseName)
+
+ # WARNING: This is likely to raise an exception!
+ # WARNING: Don't forget to check for it :)
+ self.protectedFiles = par2parser.getProtectedFiles(directory, parityFile)
+
+ # Sort so the compare works as expected
+ self.similarlyNamedFiles.sort()
+ self.protectedFiles.sort()
+
+ ############################################################################
+
+ def __eq__(self, rhs):
+
+ return self.directory == rhs.directory \
+ and self.baseName == rhs.baseName \
+ and self.similarlyNamedFiles == rhs.similarlyNamedFiles \
+ and self.protectedFiles == rhs.protectedFiles
+
+ ############################################################################
+
+ def __str__(self):
+ s = '%s\n' % repr(self)
+ s += 'directory: %s\n' % self.directory
+ s += 'parityFile: %s\n' % self.parityFile
+ s += 'baseName: %s\n' % self.baseName
+ s += 'similarlyNamedFiles:\n'
+ for f in self.similarlyNamedFiles:
+ s += '-> %s\n' % f
+ s += 'protectedFiles:\n'
+ for f in self.protectedFiles:
+ s += '-> %s\n' % f
+
+ return s
+
+ ############################################################################
+