diff --git a/fs_uae_wrapper/file_archive.py b/fs_uae_wrapper/file_archive.py index d465115..ddeda88 100644 --- a/fs_uae_wrapper/file_archive.py +++ b/fs_uae_wrapper/file_archive.py @@ -4,6 +4,7 @@ File archive classes import os import subprocess import sys +import re class Archive(object): @@ -125,6 +126,11 @@ def get_archiver(arch_name): """Return right class for provided archive file name""" _, ext = os.path.splitext(arch_name) + re_tar = re.compile('.*([tT][aA][rR].[^.]+$)') + result = re_tar.match(arch_name) + + if result: + ext = result.groups[0] archivers = {'.tar': TarArchive, '.tgz': TarGzipArchive, diff --git a/tests/test_file_archive.py b/tests/test_file_archive.py index 7c97209..8f9bbae 100644 --- a/tests/test_file_archive.py +++ b/tests/test_file_archive.py @@ -40,6 +40,11 @@ class TestArchive(TestCase): self.assertIsNone(arch) file_archive.TarArchive.ARCH = 'tar' + with open('foobarbaz.tar.bz2', 'w') as fobj: + fobj.write('\n') + arch = file_archive.get_archiver('foobarbaz.tar.bz2') + self.assertIsInstance(arch, file_archive.TarBzip2Archive) + @mock.patch('subprocess.call') def test_archive(self, call): arch = file_archive.Archive()