Clean up program name and version code
[rarslave2.git] / PAR2Set / ExtractFirstBase.py
1 #!/usr/bin/env python
2 # vim: set ts=4 sts=4 sw=4 textwidth=92:
3
4 """
5 Holds the ExtractFirstBase class.
6 """
7
8 __author__    = "Ira W. Snyder (devel@irasnyder.com)"
9 __copyright__ = "Copyright (c) 2006,2007 Ira W. Snyder (devel@irasnyder.com)"
10 __license__   = "GNU GPL v2 (or, at your option, any later version)"
11
12 #    ExtractFirstBase.py
13 #
14 #    Copyright (C) 2006,2007  Ira W. Snyder (devel@irasnyder.com)
15 #
16 #    This program is free software; you can redistribute it and/or modify
17 #    it under the terms of the GNU General Public License as published by
18 #    the Free Software Foundation; either version 2 of the License, or
19 #    (at your option) any later version.
20 #
21 #    This program is distributed in the hope that it will be useful,
22 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
23 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24 #    GNU General Public License for more details.
25 #
26 #    You should have received a copy of the GNU General Public License
27 #    along with this program; if not, write to the Free Software
28 #    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
29
30 import logging
31 import PAR2Set.Base
32 import rsutil.common
33
34 class ExtractFirstBase (PAR2Set.Base.Base):
35         """Base class for PAR2Set types which run the extraction routine before
36         the repair routine"""
37
38         def runAll (self):
39                 """Run the extraction, repair, and delete stages"""
40
41                 # Extraction Stage
42                 ret = self.runExtract ()
43
44                 if ret != rsutil.common.SUCCESS:
45                         logging.critical ('Extraction stage failed for: %s' % self.p2file)
46                         return -rsutil.common.EEXTRACT
47
48                 self.update_matches ()
49
50                 # Repair Stage
51                 ret = self.runVerifyAndRepair ()
52
53                 if ret != rsutil.common.SUCCESS:
54                         logging.critical ('Repair stage failed for: %s' % self.p2file)
55                         return -rsutil.common.ECHECK
56
57                 self.update_matches ()
58
59                 # Deletion Stage
60                 ret = self.runDelete ()
61
62                 if ret != rsutil.common.SUCCESS:
63                         logging.critical ('Deletion stage failed for: %s' % self.p2file)
64                         return -rsutil.common.EDELETE
65
66                 logging.info ('Successfully completed: %s' % self.p2file)
67                 return rsutil.common.SUCCESS
68