2 # vim: set ts=4 sts=4 sw=4 textwidth=92:
5 Holds the NoExtract class.
7 This module works with sets that only need to repair and delete, and do
8 not need any extraction.
10 It will detect sets like the following:
19 Where the PAR2 files protect the mp3 files directly.
21 NOTE: It doesn't just detect mp3's, it will detect any set that does not
22 NOTE: have any extractable elements in it.
25 __author__ = "Ira W. Snyder (devel@irasnyder.com)"
26 __copyright__ = "Copyright (c) 2006,2007 Ira W. Snyder (devel@irasnyder.com)"
27 __license__ = "GNU GPL v2 (or, at your option, any later version)"
31 # Copyright (C) 2006,2007 Ira W. Snyder (devel@irasnyder.com)
33 # This program is free software; you can redistribute it and/or modify
34 # it under the terms of the GNU General Public License as published by
35 # the Free Software Foundation; either version 2 of the License, or
36 # (at your option) any later version.
38 # This program is distributed in the hope that it will be useful,
39 # but WITHOUT ANY WARRANTY; without even the implied warranty of
40 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
41 # GNU General Public License for more details.
43 # You should have received a copy of the GNU General Public License
44 # along with this program; if not, write to the Free Software
45 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
52 def detector (name_files, prot_files):
53 """Detector for the NoExtract type"""
55 EXTRACT_REGEX = rsutil.common.config_get_value ('regular expressions', 'extractable_regex')
56 return not rsutil.common.has_a_match (EXTRACT_REGEX, prot_files)
59 class NoExtract (PAR2Set.Base.Base):
61 """Class for sets that do not need to be extracted. Note that this is not a
62 base class, this is a working class."""
68 """Run the Repair and Deletion stages, omitting the Extraction stage"""
71 ret = self.runVerifyAndRepair ()
73 if ret != rsutil.common.SUCCESS:
74 logging.critical ('Repair stage failed for: %s' % self.p2file)
75 return -rsutil.common.ECHECK
77 self.update_matches ()
80 ret = self.runDelete ()
82 if ret != rsutil.common.SUCCESS:
83 logging.critical ('Deletion stage failed for: %s' % self.p2file)
84 return -rsutil.common.EDELETE
86 logging.info ('Successfully completed: %s' % self.p2file)
87 return rsutil.common.SUCCESS