Example #1
0
def get_archive_cmdlist_func (program, command, format):
    # get python module for given archive program
    key = util.stripext(os.path.basename(program).lower())
    module = ProgramModules.get(key, key)
    # import archive handler function (eg. patoolib.programs.star.extract_tar)
    args = (module, command, format)
    import_cmd = "from patoolib.programs.%s import %s_%s as func" % args
    try:
        exec import_cmd
    except ImportError:
        raise util.PatoolError('ImportError executing %r' % import_cmd)
    return locals()['func']
Example #2
0
def stripext (cmd, archive):
    """Print the name without suffix."""
    print util.stripext(archive)
    return None
Example #3
0
 def test_stripext(self):
     self.assertTrue(util.stripext("bar.gz") == "bar")
     self.assertTrue(util.stripext("foo/bar.tar.gz") == "bar")
     self.assertTrue(util.stripext("foo/bartar.gz") == "bartar")
     self.assertTrue(util.stripext("foo/bar.7z") == "bar")
     self.assertTrue(util.stripext("foo/bar") == "bar")