Move common functionality into rsutil package
[rarslave2.git] / PAR2Set / Join.py
index c2b055f..58648fa 100644 (file)
@@ -3,7 +3,7 @@
 
 import logging
 import PAR2Set.Base
-from RarslaveCommon import *
+import rsutil.common
 
 #
 # This is a regular joined file type
@@ -21,8 +21,8 @@ from RarslaveCommon import *
 #
 
 def detector (name_files, prot_files):
-       return has_a_match ('^.*\.\d\d\d$', name_files) \
-                       and not has_a_match ('^.*\.\d\d\d$', prot_files)
+       return rsutil.common.has_a_match ('^.*\.\d\d\d$', name_files) \
+                       and not rsutil.common.has_a_match ('^.*\.\d\d\d$', prot_files)
 
 
 class Join (PAR2Set.Base.Base):
@@ -31,10 +31,10 @@ class Join (PAR2Set.Base.Base):
                return 'JOIN'
 
        def find_joinfiles (self):
-               return find_matches ('^.*\.\d\d\d$', self.name_matched_files)
+               return rsutil.common.find_matches ('^.*\.\d\d\d$', self.name_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]
@@ -48,7 +48,7 @@ class Join (PAR2Set.Base.Base):
                        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:
@@ -63,14 +63,14 @@ class Join (PAR2Set.Base.Base):
        def extraction_function (self, file, todir):
                """Extract a single file of this type to the given directory"""
 
-               NOEXTRACT_CMD = config_get_value ('commands', 'noextract')
+               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 SUCCESS
 
                cmd = NOEXTRACT_CMD % (file, todir)
-               ret = run_command (cmd)
+               ret = rsutil.common.run_command (cmd)
 
                # Check error code
                if ret != 0: