Add support for Join sets where the parity protects the split files
[rarslave2.git] / PAR2Set / ExtractFirstOldRAR.py
1 #!/usr/bin/env python
2 # vim: set ts=4 sts=4 sw=4 textwidth=92:
3
4 """
5 Holds the ExtractFirstOldRAR class.
6
7 This module works with old-style rar sets which need to be extracted
8 before they are verified.
9
10 It will detect sets like the following:
11 X.par2
12 X.vol0+1.par2
13 ...
14
15 X.rar
16 X.r00
17 X.r01
18 ...
19
20 Where the PAR2 files do not protect the rar files directly, but instead
21 protect the files contained inside the rar files.
22 """
23
24 __author__    = "Ira W. Snyder (devel@irasnyder.com)"
25 __copyright__ = "Copyright (c) 2006,2007 Ira W. Snyder (devel@irasnyder.com)"
26 __license__   = "GNU GPL v2 (or, at your option, any later version)"
27
28 #    ExtractFirstOldRAR.py -- detect and work with a old-style rar set
29 #
30 #    Copyright (C) 2006,2007  Ira W. Snyder (devel@irasnyder.com)
31 #
32 #    This program is free software; you can redistribute it and/or modify
33 #    it under the terms of the GNU General Public License as published by
34 #    the Free Software Foundation; either version 2 of the License, or
35 #    (at your option) any later version.
36 #
37 #    This program is distributed in the hope that it will be useful,
38 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
39 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
40 #    GNU General Public License for more details.
41 #
42 #    You should have received a copy of the GNU General Public License
43 #    along with this program; if not, write to the Free Software
44 #    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
45
46 from PAR2Set import ExtractFirstBase, OldRAR, utils
47
48 class ExtractFirstOldRAR(ExtractFirstBase, OldRAR):
49
50     def detect(self):
51         regex = r'^.*\.r00$'
52         m1 = utils.hasAMatch(regex, self.similarlyNamedFiles)
53         m2 = utils.hasAMatch(regex, self.protectedFiles)
54
55         if m1 and not m2:
56             return
57
58         raise TypeError
59