X-Git-Url: https://www.irasnyder.com/gitweb/?a=blobdiff_plain;f=PAR2Set%2FExtractFirstNewRAR.py;h=723d1ed5b3a094dbaad6790b644470c400f4ba94;hb=fb1d40ac55ebda23533f30c47ee74b62b120b111;hp=6b90591486852d35fdacc5e09a57c307ce06f120;hpb=915d5e7efd472b541ca06bd4b28ce3ab2e0e7efc;p=rarslave2.git diff --git a/PAR2Set/ExtractFirstNewRAR.py b/PAR2Set/ExtractFirstNewRAR.py index 6b90591..723d1ed 100644 --- a/PAR2Set/ExtractFirstNewRAR.py +++ b/PAR2Set/ExtractFirstNewRAR.py @@ -1,39 +1,58 @@ #!/usr/bin/env python # vim: set ts=4 sts=4 sw=4 textwidth=92: -import PAR2Set_NEWRAR -import PAR2Set_EXTRACTFIRST -from RarslaveCommon import * +""" +Holds the ExtractFirstNewRAR class. +This module works with new-style rar sets which need to be extracted +before they are verified. + +It will detect sets like the following: +X.par2 +X.vol0+1.par2 +... + +X.part01.rar +X.part02.rar +... + +Where the PAR2 files do not protect the rar files directly, but instead +protect the files contained inside the rar files. +""" + +__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)" + +# ExtractFirstNewRAR.py -- detect and work with a new-style rar set # -# This is an old-style rar type -# -# It will detect sets like the following: -# X.par2 -# X.vol0+1.par2 -# X.vol1+2.par2 -# X.rar -# X.r00 -# X.r01 -# -# OR +# Copyright (C) 2006,2007 Ira W. Snyder (devel@irasnyder.com) # -# ABC.rar -# ABC.r00 -# ABC.r01 +# 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 all files that do not match in basename -# with the PAR2 file itself. +# 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 ExtractFirstBase, NewRAR, utils -def detect_EF_NEWRAR (name_files, prot_files): - return has_a_match ('^.*\.part0*1\.rar$', name_files) \ - and not has_a_match ('^.*\.part0*1\.rar$', prot_files) +class ExtractFirstNewRAR(ExtractFirstBase, NewRAR): + def detect(self): + regex = r'^.*\.part0*1\.rar$' + m1 = utils.hasAMatch(regex, self.similarlyNamedFiles) + m2 = utils.hasAMatch(regex, self.protectedFiles) -class PAR2Set_EF_NEWRAR (PAR2Set_EXTRACTFIRST.PAR2Set_EXTRACTFIRST, - PAR2Set_NEWRAR.PAR2Set_NEWRAR): + if m1 and not m2: + return - def __repr__ (self): - return 'EXTRACTFIRST NEWRAR' + raise TypeError