X-Git-Url: https://www.irasnyder.com/gitweb/?p=rarslave2.git;a=blobdiff_plain;f=PAR2Set%2FJoin.py;h=1dd680a668998482bded1b824eff12d2bafdda46;hp=b764c499be11408fafaaadd88272221c7984fce7;hb=3e0a5dd7c7549636eb70c6a641987da66742f1db;hpb=44cd23f16a5a184adb1d8890633a0e432a2e5636 diff --git a/PAR2Set/Join.py b/PAR2Set/Join.py index b764c49..1dd680a 100644 --- a/PAR2Set/Join.py +++ b/PAR2Set/Join.py @@ -42,6 +42,7 @@ __license__ = "GNU GPL v2 (or, at your option, any later version)" # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +import re import os import logging import PAR2Set.Base @@ -74,28 +75,17 @@ class Join (PAR2Set.Base.Base): This is done using the par2repair command by default""" - PAR2_CMD = rsutil.common.config_get_value ('commands', 'par2repair') + rsutil.common.run_command(['par2repair'] + self.all_p2files + self.find_joinfiles(), self.dir) - # assemble the command - # par2repair -- PAR2 PAR2_EXTRA [JOIN_FILES] - command = "%s \"%s\" " % (PAR2_CMD, self.p2file) + def find_deleteable_files (self): + """Find all files which are deletable by using the regular expression from the + configuration file""" - for f in self.all_p2files: - if f != self.p2file: - command += "\"%s\" " % os.path.split (f)[1] + DELETE_REGEX = rsutil.common.config_get_value ('regular expressions', 'delete_regex') + dregex = re.compile (DELETE_REGEX, re.IGNORECASE) - for f in self.find_joinfiles (): - command += "\"%s\" " % os.path.split (f)[1] - - # run the command - ret = rsutil.common.run_command (command, self.dir) - - # check the result - if ret != 0: - logging.critical ('PAR2 Check / Repair failed: %s' % self.p2file) - return -rsutil.common.ECHECK - - return rsutil.common.SUCCESS + return [f for f in self.all_files if dregex.match (f) and \ + f not in self.prot_matched_files] def find_extraction_heads (self): """Find the extraction heads. Since this should not be an extractable set, @@ -112,18 +102,5 @@ class Join (PAR2Set.Base.Base): This command ignores the extraction if file and todir+file are the same file. This keeps things like mv working smoothly.""" - NOEXTRACT_CMD = rsutil.common.config_get_value ('commands', 'noextract') - - # Make sure that both files are not the same file. If they are, don't run at all. - if os.path.samefile (file, os.path.join (todir, file)): - return rsutil.common.SUCCESS - - cmd = NOEXTRACT_CMD % (file, todir) - ret = rsutil.common.run_command (cmd) - - # Check error code - if ret != 0: - return -rsutil.common.EEXTRACT - - return rsutil.common.SUCCESS - + # The Join type doesn't need any extraction + pass