Major Update
[rarslave2.git] / PAR2Set / ZIP.py
index 39a83ff..75c8169 100644 (file)
@@ -1,5 +1,5 @@
 #!/usr/bin/env python
 #!/usr/bin/env python
-# vim: set ts=4 sts=4 sw=4 textwidth=92:
+# vim: set ts=4 sts=4 sw=4 textwidth=80:
 
 """
 Holds the ZIP class.
 
 """
 Holds the ZIP class.
@@ -19,7 +19,7 @@ X, but is not required to be.
 """
 
 __author__    = "Ira W. Snyder (devel@irasnyder.com)"
 """
 
 __author__    = "Ira W. Snyder (devel@irasnyder.com)"
-__copyright__ = "Copyright (c) 2006,2007 Ira W. Snyder (devel@irasnyder.com)"
+__copyright__ = "Copyright (c) 2006-2008 Ira W. Snyder (devel@irasnyder.com)"
 __license__   = "GNU GPL v2 (or, at your option, any later version)"
 
 #    ZIP.py -- detect and work with zip sets
 __license__   = "GNU GPL v2 (or, at your option, any later version)"
 
 #    ZIP.py -- detect and work with zip sets
@@ -40,34 +40,30 @@ __license__   = "GNU GPL v2 (or, at your option, any later version)"
 #    along with this program; if not, write to the Free Software
 #    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 #    along with this program; if not, write to the Free Software
 #    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
-import PAR2Set.Base
-import rsutil.common
+from PAR2Set import Base, utils
 
 
+class ZIP(Base):
 
 
-def detector (name_files, prot_files):
-       """Detect a zip set"""
+    ############################################################################
 
 
-       all_files = rsutil.common.no_duplicates (name_files + prot_files)
-       return rsutil.common.has_a_match ('^.*\.zip$', all_files)
+    def detect(self):
 
 
+        regex = r'^.*\.zip$'
 
 
-class ZIP (PAR2Set.Base.Base):
+        if utils.hasAMatch(regex, self.allFiles):
+            return
 
 
-       """Class for working with normal zip sets"""
+        raise TypeError
 
 
-       def __repr__ (self):
-               return 'ZIP'
+    ############################################################################
 
 
-       def find_extraction_heads (self):
-               """Find the heads of extraction for a zip set"""
+    def extract(self):
 
 
-               return rsutil.common.find_matches ('^.*\.zip', self.all_files)
+        regex = r'^.*\.zip$'
+        files = utils.findMatches(regex, self.allFiles)
 
 
-       def extraction_function (self, file, todir):
-               """Extract a single zip file to the given directory.
+        for f in files:
+            utils.runCommand(['unzip', f], todir)
 
 
-                  file -- the file to extract
-                  todir -- the directory to extract into"""
-
-               rsutil.common.run_command(['unzip', file], todir)
+    ############################################################################