X-Git-Url: https://www.irasnyder.com/gitweb/?p=rarslave2.git;a=blobdiff_plain;f=PAR2Set%2FZIP.py;fp=PAR2Set%2FZIP.py;h=75c8169d2e7b8f7de8914643a0e94c74de53ce0b;hp=39a83ff1f1c32687dd2077976f4e44ff876a6aca;hb=feeefeb8ea2f1e4724424d43c0eb872aee4743c2;hpb=3e0a5dd7c7549636eb70c6a641987da66742f1db diff --git a/PAR2Set/ZIP.py b/PAR2Set/ZIP.py index 39a83ff..75c8169 100644 --- a/PAR2Set/ZIP.py +++ b/PAR2Set/ZIP.py @@ -1,5 +1,5 @@ #!/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. @@ -19,7 +19,7 @@ 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)" +__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 @@ -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 -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) + ############################################################################