mirror of
https://github.com/gryf/fs-uae-wrapper.git
synced 2025-12-21 13:28:04 +01:00
Fix for archives like .tar.bz2
This commit is contained in:
@@ -4,6 +4,7 @@ File archive classes
|
|||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
import re
|
||||||
|
|
||||||
|
|
||||||
class Archive(object):
|
class Archive(object):
|
||||||
@@ -125,6 +126,11 @@ def get_archiver(arch_name):
|
|||||||
"""Return right class for provided archive file name"""
|
"""Return right class for provided archive file name"""
|
||||||
|
|
||||||
_, ext = os.path.splitext(arch_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,
|
archivers = {'.tar': TarArchive,
|
||||||
'.tgz': TarGzipArchive,
|
'.tgz': TarGzipArchive,
|
||||||
|
|||||||
@@ -40,6 +40,11 @@ class TestArchive(TestCase):
|
|||||||
self.assertIsNone(arch)
|
self.assertIsNone(arch)
|
||||||
file_archive.TarArchive.ARCH = 'tar'
|
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')
|
@mock.patch('subprocess.call')
|
||||||
def test_archive(self, call):
|
def test_archive(self, call):
|
||||||
arch = file_archive.Archive()
|
arch = file_archive.Archive()
|
||||||
|
|||||||
Reference in New Issue
Block a user