2 # vim: set ts=4 sts=4 sw=4 textwidth=92:
5 from RarslaveCommon import *
8 # This is a regular joined file type
10 # It will detect sets like the following:
18 # Where the PAR2 files protect a file named X.avi (or similar). It will not
19 # work where the PAR2 files are protecting the .001, etc files directly.
22 def detect_JOIN (name_files, prot_files):
23 return has_a_match ('^.*\.\d\d\d$', name_files)
26 class PAR2Set_JOIN (PAR2Set.PAR2Set):
31 def find_joinfiles (self):
32 return find_matches ('^.*\.\d\d\d$', self.name_matched_files)
34 def runVerifyAndRepair (self):
35 PAR2_CMD = config_get_value ('commands', 'par2repair')
37 # assemble the command
38 # par2repair -- PAR2 PAR2_EXTRA [JOIN_FILES]
39 command = "%s \"%s\" " % (PAR2_CMD, self.p2file)
41 for f in self.all_p2files:
43 command += "\"%s\" " % os.path.split (f)[1]
45 for f in self.find_joinfiles ():
46 command += "\"%s\" " % os.path.split (f)[1]
49 ret = run_command (command, self.dir)
53 fatalMessage ('PAR2 Check / Repair failed: %s' % self.p2file)
58 def find_extraction_heads (self):
59 return self.prot_matched_files
61 def extraction_function (self, file, todir):
62 """Extract a single file of this type to the given directory"""
64 NOEXTRACT_CMD = config_get_value ('commands', 'noextract')
66 # Make sure that both files are not the same file. If they are, don't run at all.
67 if os.path.samefile (file, os.path.join (todir, file)):
70 cmd = NOEXTRACT_CMD % (file, todir)
71 ret = run_command (cmd)