#!/usr/bin/env python
# vim: set ts=4 sts=4 sw=4 textwidth=92:
-import PAR2Set
-from RarslaveCommon import *
+"""
+Holds the ZIP class.
+This module works with regular zip file sets.
+
+It will detect sets like the following:
+X.par2
+X.vol0+1.par2
+...
+
+Y.zip
+...
+
+Where the PAR2 files protect the Y.zip file(s). Note that Y can be equal to
+X, but is not required to be.
+"""
+
+__author__ = "Ira W. Snyder (devel@irasnyder.com)"
+__copyright__ = "Copyright (c) 2006,2007 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
#
-# This is a regular zip file type
+# Copyright (C) 2006,2007 Ira W. Snyder (devel@irasnyder.com)
#
-# It will detect sets like the following:
-# X.par2
-# X.vol0+1.par2
-# X.vol1+2.par2
-# X.zip
-# ABC.zip
+# 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.
#
-# Where the PAR2 files protect a file named X.zip and/or ABC.zip.
+# 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
+
+import PAR2Set.Base
+import rsutil.common
-def detect_ZIP (name_files, prot_files):
- all_files = no_duplicates (name_files + prot_files)
- return has_a_match ('^.*\.zip$', all_files)
+def detector (name_files, prot_files):
+ """Detect a zip set"""
-class PAR2Set_ZIP (PAR2Set.PAR2Set):
+ all_files = rsutil.common.no_duplicates (name_files + prot_files)
+ return rsutil.common.has_a_match ('^.*\.zip$', all_files)
+
+
+class ZIP (PAR2Set.Base.Base):
+
+ """Class for working with normal zip sets"""
def __repr__ (self):
return 'ZIP'
def find_extraction_heads (self):
- return find_matches ('^.*\.zip', self.all_files)
+ """Find the heads of extraction for a zip set"""
+
+ return rsutil.common.find_matches ('^.*\.zip', self.all_files)
def extraction_function (self, file, todir):
- ZIP_CMD = self.config_get_value ('commands', 'unzip')
+ """Extract a single zip file to the given directory.
+
+ file -- the file to extract
+ todir -- the directory to extract into"""
+
+ ZIP_CMD = rsutil.common.config_get_value ('commands', 'unzip')
cmd = ZIP_CMD % (file, todir)
- ret = run_command (cmd)
+ ret = rsutil.common.run_command (cmd)
# Check error code
if ret != 0:
- return -EEXTRACT
+ return -rsutil.common.EEXTRACT
- return SUCCESS
+ return rsutil.common.SUCCESS