#!/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.
"""
__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
# 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)
+ ############################################################################