Add 7z file support #3906

This commit is contained in:
Andrew Rogl 2021-05-07 22:04:46 +10:00
parent 2fa3717731
commit 533559136e
5 changed files with 17 additions and 0 deletions

View file

@ -1054,6 +1054,12 @@ class ArchiveImportTask(SentinelImportTask):
pass
else:
cls._handlers.append((is_rarfile, RarFile))
try:
from py7zr import is_7zfile, SevenZipFile
except ImportError:
pass
else:
cls._handlers.append((is_7zfile, SevenZipFile))
return cls._handlers

View file

@ -214,6 +214,10 @@ Other new things:
``check_on_import`` config option.
* :doc:`/plugins/export`: big speedups when `--include-keys` option is used
Thanks to :user:`ssssam`.
* Added 7z support via the `py7zr`_ library
Thanks to :user:`arogl`. :bug:`3906`
.. _py7zr: https://github.com/miurahr/py7zr
Fixes:

View file

@ -122,6 +122,7 @@ setup(
'responses>=0.3.0',
'requests_oauthlib',
'reflink',
'py7zr',
] + (
# Tests for the thumbnails plugin need pathlib on Python 2 too.
['pathlib'] if (sys.version_info < (3, 4, 0)) else []

BIN
test/rsrc/archive.7z Normal file

Binary file not shown.

View file

@ -450,6 +450,12 @@ class ImportRarTest(ImportZipTest):
return os.path.join(_common.RSRC, b'archive.rar')
class Import7zTest(ImportZipTest):
def create_archive(self):
return os.path.join(_common.RSRC, b'archive.7z')
@unittest.skip('Implement me!')
class ImportPasswordRarTest(ImportZipTest):