Import rar archives

This commit is contained in:
Thomas Scholtes 2014-04-15 17:42:16 +02:00
parent e3acdd0cc8
commit 68595ee09d
5 changed files with 26 additions and 0 deletions

View file

@ -548,6 +548,10 @@ class ImportTask(object):
class ArchiveImportTask(ImportTask):
"""Additional methods for handling archives.
Use when `toppath` points to a `zip`, `tar`, or `rar` archive.
"""
def __init__(self, toppath):
super(ArchiveImportTask, self).__init__(toppath)
@ -582,6 +586,13 @@ class ArchiveImportTask(ImportTask):
cls._handlers.append((is_zipfile, ZipFile))
from tarfile import is_tarfile, TarFile
cls._handlers.append((is_tarfile, TarFile))
try:
from rarfile import is_rarfile, RarFile
except ImportError:
pass
else:
cls._handlers.append((is_rarfile, RarFile))
return cls._handlers
def cleanup(self):

View file

@ -99,6 +99,7 @@ setup(
'echonest_tempo': ['pyechonest'],
'lastgenre': ['pylast'],
'web': ['flask'],
'import': ['rarfile'],
},
# Non-Python/non-PyPI plugin dependencies:
# replaygain: mp3gain || aacgain

BIN
test/rsrc/archive.rar Normal file

Binary file not shown.

View file

@ -342,6 +342,19 @@ class ImportTarTest(ImportZipTest):
return path
class ImportRarTest(ImportZipTest):
def create_archive(self):
return os.path.join(_common.RSRC, 'archive.rar')
@unittest.skip('Implment me!')
class ImportPasswordRarTest(ImportZipTest):
def create_archive(self):
return os.path.join(_common.RSRC, 'password.rar')
class ImportSingletonTest(_common.TestCase, ImportHelper):
"""Test ``APPLY`` and ``ASIS`` choices for an import session with singletons
config set to True.

View file

@ -14,6 +14,7 @@ deps =
flask
responses
pyechonest
rarfile
commands =
nosetests {posargs}