PAR2Set/ZIP: fix output directory
[rarslave2.git] / PAR2Set / NewRAR.py
1 #!/usr/bin/env python
2 # vim: set ts=4 sts=4 sw=4 textwidth=92:
3
4 """Holds the NewRAR class.
5
6 This is a new-style rar type.
7
8 It will detect sets like the following:
9 X.par2
10 X.vol0+1.par2
11 ...
12
13 Y.part01.rar
14 Y.part02.rar
15 ...
16
17 Where the PAR2 files protect the rar files directly. Y can (but is not required
18 to be) the same as X.
19 """
20
21 __author__    = "Ira W. Snyder (devel@irasnyder.com)"
22 __copyright__ = "Copyright (c) 2006,2007 Ira W. Snyder (devel@irasnyder.com)"
23 __license__   = "GNU GPL v2 (or, at your option, any later version)"
24
25 #    NewRAR.py -- detect and work with a new-style rar set
26 #
27 #    Copyright (C) 2006,2007  Ira W. Snyder (devel@irasnyder.com)
28 #
29 #    This program is free software; you can redistribute it and/or modify
30 #    it under the terms of the GNU General Public License as published by
31 #    the Free Software Foundation; either version 2 of the License, or
32 #    (at your option) any later version.
33 #
34 #    This program is distributed in the hope that it will be useful,
35 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
36 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
37 #    GNU General Public License for more details.
38 #
39 #    You should have received a copy of the GNU General Public License
40 #    along with this program; if not, write to the Free Software
41 #    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
42
43 from PAR2Set import Base, utils
44
45 class NewRAR(Base):
46
47     ############################################################################
48
49     def detect(self):
50         if not utils.hasAMatch('^.*\.part0*1\.rar$', self.protectedFiles):
51             raise TypeError
52
53     ############################################################################
54
55     def extract(self):
56         files = utils.findMatches('^.*\.part0*1\.rar$', self.protectedFiles)
57
58         for f in files:
59             utils.runCommand(['unrar', 'x', '-o+', f], self.directory)
60
61     ############################################################################
62