X-Git-Url: https://www.irasnyder.com/gitweb/?a=blobdiff_plain;f=PAR2Set%2FBase.py;h=46a69deb4f0d1ed75306b76306dc1595f04d6ba4;hb=a41f0878f0745f3026f4f610eeb52cba42f03da1;hp=012c01a960a0b3e01905397bc061751a6f88914d;hpb=807fadd16633dba83c40d863a3d38a43a00f1e61;p=rarslave2.git diff --git a/PAR2Set/Base.py b/PAR2Set/Base.py index 012c01a..46a69de 100644 --- a/PAR2Set/Base.py +++ b/PAR2Set/Base.py @@ -1,8 +1,7 @@ #!/usr/bin/env python # vim: set ts=4 sts=4 sw=4 textwidth=92: -from RarslaveCommon import * -import Par2Parser +import rsutil.common import re import os @@ -45,34 +44,34 @@ class Base (object): # The real "meat" of the class self.dir = dir self.p2file = p2file - self.basename = get_basename (p2file) + self.basename = rsutil.common.get_basename (p2file) # Find files that match by name only - self.name_matched_files = find_name_matches (self.dir, self.basename) + self.name_matched_files = rsutil.common.find_name_matches (self.dir, self.basename) # Find all par2 files for this set using name matches - self.all_p2files = find_par2_files (self.name_matched_files) + self.all_p2files = rsutil.common.find_par2_files (self.name_matched_files) # Try to get the protected files for this set - self.prot_matched_files = parse_all_par2 (self.dir, self.p2file, self.all_p2files) + self.prot_matched_files = rsutil.common.parse_all_par2 (self.dir, self.p2file, self.all_p2files) # Setup the all_files combined set (for convenience only) - self.all_files = no_duplicates (self.name_matched_files + self.prot_matched_files) + self.all_files = rsutil.common.no_duplicates (self.name_matched_files + self.prot_matched_files) def __eq__ (self, rhs): return (self.dir == rhs.dir) and (self.basename == rhs.basename) and \ - list_eq (self.name_matched_files, rhs.name_matched_files) and \ - list_eq (self.prot_matched_files, rhs.prot_matched_files) + rsutil.common.list_eq (self.name_matched_files, rhs.name_matched_files) and \ + rsutil.common.list_eq (self.prot_matched_files, rhs.prot_matched_files) def update_matches (self): """Updates the contents of instance variables which are likely to change after running an operation, usually one which will create new files.""" - self.name_matched_files = find_name_matches (self.dir, self.basename) - self.all_files = no_duplicates (self.name_matched_files + self.prot_matched_files) + self.name_matched_files = rsutil.common.find_name_matches (self.dir, self.basename) + self.all_files = rsutil.common.no_duplicates (self.name_matched_files + self.prot_matched_files) def runVerifyAndRepair (self): - PAR2_CMD = config_get_value ('commands', 'par2repair') + PAR2_CMD = rsutil.common.config_get_value ('commands', 'par2repair') # assemble the command # par2repair -- PAR2 PAR2_EXTRA [JOIN_FILES] @@ -83,7 +82,7 @@ class Base (object): command += "\"%s\" " % os.path.split (f)[1] # run the command - ret = run_command (command, self.dir) + ret = rsutil.common.run_command (command, self.dir) # check the result if ret != 0: @@ -93,7 +92,7 @@ class Base (object): return SUCCESS def find_deleteable_files (self): - DELETE_REGEX = config_get_value ('regular expressions', 'delete_regex') + DELETE_REGEX = rsutil.common.config_get_value ('regular expressions', 'delete_regex') dregex = re.compile (DELETE_REGEX, re.IGNORECASE) return [f for f in self.all_files if dregex.match (f)] @@ -133,7 +132,7 @@ class Base (object): def runDelete (self): deleteable_files = self.find_deleteable_files () ret = self.delete_list_of_files (self.dir, deleteable_files, \ - options_get_value ('interactive')) + rsutil.common.options_get_value ('interactive')) return ret @@ -198,7 +197,7 @@ class Base (object): # Call the extraction function on each head for h in self.find_extraction_heads (): - full_head = full_abspath (os.path.join (self.dir, h)) + full_head = rsutil.common.full_abspath (os.path.join (self.dir, h)) ret = self.extraction_function (full_head, todir) logging.debug ('Extraction Function returned: %d' % ret)