2 # vim: set ts=4 sts=4 sw=4 textwidth=92:
6 from RarslaveCommon import *
9 # This is a regular joined file type
11 # It will detect sets like the following:
19 # Where the PAR2 files protect a file named X.avi (or similar). It will not
20 # work where the PAR2 files are protecting the .001, etc files directly.
23 def detect_JOIN (name_files, prot_files):
24 return has_a_match ('^.*\.\d\d\d$', name_files) \
25 and not has_a_match ('^.*\.\d\d\d$', prot_files)
28 class PAR2Set_JOIN (PAR2Set.PAR2Set):
33 def find_joinfiles (self):
34 return find_matches ('^.*\.\d\d\d$', self.name_matched_files)
36 def runVerifyAndRepair (self):
37 PAR2_CMD = config_get_value ('commands', 'par2repair')
39 # assemble the command
40 # par2repair -- PAR2 PAR2_EXTRA [JOIN_FILES]
41 command = "%s \"%s\" " % (PAR2_CMD, self.p2file)
43 for f in self.all_p2files:
45 command += "\"%s\" " % os.path.split (f)[1]
47 for f in self.find_joinfiles ():
48 command += "\"%s\" " % os.path.split (f)[1]
51 ret = run_command (command, self.dir)
55 logging.critical ('PAR2 Check / Repair failed: %s' % self.p2file)
60 def find_extraction_heads (self):
61 return self.prot_matched_files
63 def extraction_function (self, file, todir):
64 """Extract a single file of this type to the given directory"""
66 NOEXTRACT_CMD = config_get_value ('commands', 'noextract')
68 # Make sure that both files are not the same file. If they are, don't run at all.
69 if os.path.samefile (file, os.path.join (todir, file)):
72 cmd = NOEXTRACT_CMD % (file, todir)
73 ret = run_command (cmd)