diff --git a/session.vim b/session.vim index 67502c2..b7f24d3 100644 --- a/session.vim +++ b/session.vim @@ -11,7 +11,6 @@ let g:syntastic_cpp_include_dirs = [ \'/usr/include/freetype2', \'/usr/include/fontconfig', \'src/qtcurve/common', 'src/qtcurve', - \'src/unrar', \'src/qt-harfbuzz/src', \'/usr/include/ImageMagick', \] diff --git a/setup/extensions.py b/setup/extensions.py index b9d92f6..2ac13a9 100644 --- a/setup/extensions.py +++ b/setup/extensions.py @@ -224,24 +224,6 @@ extensions = [ sip_files=['calibre/ebooks/pdf/render/qt_hack.sip'] ), - Extension('unrar', - ['unrar/%s.cpp'%(x.partition('.')[0]) for x in ''' - rar.o strlist.o strfn.o pathfn.o savepos.o smallfn.o global.o file.o - filefn.o filcreat.o archive.o arcread.o unicode.o system.o - isnt.o crypt.o crc.o rawread.o encname.o resource.o match.o - timefn.o rdwrfn.o consio.o options.o ulinks.o errhnd.o rarvm.o - secpassword.o rijndael.o getbits.o sha1.o extinfo.o extract.o - volume.o list.o find.o unpack.o cmddata.o filestr.o scantree.o - '''.split()] + ['calibre/utils/unrar.cpp'], - inc_dirs=['unrar'], - cflags=[('/' if iswindows else '-') + x for x in ( - 'DSILENT', 'DRARDLL', 'DUNRAR')] + ( - [] if iswindows else ['-D_FILE_OFFSET_BITS=64', - '-D_LARGEFILE_SOURCE']), - optimize_level=2, - libraries=['User32', 'Advapi32', 'kernel32', 'Shell32'] if iswindows else [] - ), - ] diff --git a/setup/installer/windows/freeze.py b/setup/installer/windows/freeze.py index 08aa91f..7ee523b 100644 --- a/setup/installer/windows/freeze.py +++ b/setup/installer/windows/freeze.py @@ -635,7 +635,7 @@ class Win32Freeze(Command, WixMixIn): # Because of https://github.com/fancycode/MemoryModule/issues/4 # any extensions that use C++ exceptions must be loaded # from files - 'unrar.pyd', 'wpd.pyd', 'podofo.pyd', + 'wpd.pyd', 'podofo.pyd', 'progress_indicator.pyd', 'hunspell.pyd', # As per this https://bugs.launchpad.net/bugs/1087816 # on some systems magick.pyd fails to load from memory diff --git a/src/calibre/__init__.py b/src/calibre/__init__.py index fcb627c..3289865 100644 --- a/src/calibre/__init__.py +++ b/src/calibre/__init__.py @@ -271,10 +271,7 @@ def extract(path, dir): # First use the file header to identify its type with open(path, 'rb') as f: id_ = f.read(3) - if id_ == b'Rar': - from calibre.utils.unrar import extract as rarextract - extractor = rarextract - elif id_.startswith(b'PK'): + if id_.startswith(b'PK'): from calibre.libunzip import extract as zipextract extractor = zipextract if extractor is None: @@ -283,9 +280,6 @@ def extract(path, dir): if ext in ['zip', 'cbz', 'epub', 'oebzip']: from calibre.libunzip import extract as zipextract extractor = zipextract - elif ext in ['cbr', 'rar']: - from calibre.utils.unrar import extract as rarextract - extractor = rarextract if extractor is None: raise Exception('Unknown archive type') extractor(path, dir) diff --git a/src/calibre/constants.py b/src/calibre/constants.py index 13c78db..8e699e2 100644 --- a/src/calibre/constants.py +++ b/src/calibre/constants.py @@ -137,7 +137,6 @@ class Plugins(collections.Mapping): 'speedup', 'freetype', 'woff', - 'unrar', 'qt_hack', '_regex', 'hunspell', diff --git a/src/calibre/customize/builtins.py b/src/calibre/customize/builtins.py index a74951c..86aa14d 100644 --- a/src/calibre/customize/builtins.py +++ b/src/calibre/customize/builtins.py @@ -142,10 +142,6 @@ class ComicMetadataReader(MetadataReaderPlugin): ftype = 'cbr' elif id_.startswith(b'PK'): ftype = 'cbz' - if ftype == 'cbr': - from calibre.utils.unrar import extract_first_alphabetically as extract_first - extract_first - else: from calibre.libunzip import extract_member extract_first = functools.partial(extract_member, sort_alphabetically=True) diff --git a/src/calibre/ebooks/metadata/archive.py b/src/calibre/ebooks/metadata/archive.py index 7b8ecd2..2910280 100644 --- a/src/calibre/ebooks/metadata/archive.py +++ b/src/calibre/ebooks/metadata/archive.py @@ -27,8 +27,6 @@ def archive_type(stream): ans = None if id_ == stringFileHeader: ans = 'zip' - elif id_.startswith('Rar'): - ans = 'rar' try: stream.seek(pos) except: @@ -40,29 +38,20 @@ class ArchiveExtract(FileTypePlugin): name = 'Archive Extract' author = 'Kovid Goyal' description = _('Extract common e-book formats from archives ' - '(zip/rar) files. Also try to autodetect if they are actually ' - 'cbz/cbr files.') + 'zip files. Also try to autodetect if they are actually ' + 'cbz files.') file_types = set(['zip', 'rar']) supported_platforms = ['windows', 'osx', 'linux'] on_import = True def run(self, archive): from calibre.utils.zipfile import ZipFile - is_rar = archive.lower().endswith('.rar') - if is_rar: - from calibre.utils.unrar import extract_member, names - else: - zf = ZipFile(archive, 'r') - - if is_rar: - with open(archive, 'rb') as rf: - fnames = list(names(rf)) - else: - fnames = zf.namelist() + zf = ZipFile(archive, 'r') + fnames = zf.namelist() fnames = [x for x in fnames if '.' in x and x.lower().rpartition('/')[-1] != 'thumbs.db'] if is_comic(fnames): - ext = '.cbr' if is_rar else '.cbz' + ext = '.cbz' of = self.temporary_file('_archive_extract'+ext) with open(archive, 'rb') as f: of.write(f.read()) @@ -78,12 +67,7 @@ class ArchiveExtract(FileTypePlugin): of = self.temporary_file('_archive_extract.'+ext) with closing(of): - if is_rar: - with open(archive, 'rb') as f: - data = extract_member(f, match=None, name=fname)[1] - of.write(data) - else: - of.write(zf.read(fname)) + of.write(zf.read(fname)) return of.name def get_comic_book_info(d, mi, series_index='volume'): @@ -141,10 +125,6 @@ def get_comic_metadata(stream, stream_type, series_index='volume'): from calibre.utils.zipfile import ZipFile zf = ZipFile(stream) comment = zf.comment - elif stream_type == 'cbr': - from calibre.utils.unrar import RARFile - f = RARFile(stream, get_comment=True) - comment = f.comment if comment: import json diff --git a/src/calibre/gui2/add.py b/src/calibre/gui2/add.py index d849846..50aa6d9 100644 --- a/src/calibre/gui2/add.py +++ b/src/calibre/gui2/add.py @@ -84,11 +84,8 @@ class RecursiveFind(QThread): # {{{ prints('Corrupt ZIP file, trying to use local headers') from calibre.utils.localunzip import extractall extractall(self.path, self.tdir) - elif self.path.lower().endswith('.rar'): - from calibre.utils.unrar import extract - extract(self.path, self.tdir) else: - raise ValueError('Can only process ZIP or RAR archives') + raise ValueError('Can only process ZIP archives') def run(self): if self.tdir is not None: @@ -292,7 +289,7 @@ class Adder(QObject): # {{{ self.pd.canceled_signal.connect(self.canceled) def add_recursive(self, root, single=True): - if os.path.exists(root) and os.path.isfile(root) and root.lower().rpartition('.')[-1] in {'zip', 'rar'}: + if os.path.exists(root) and os.path.isfile(root) and root.lower().rpartition('.')[-1] in {'zip'}: self.path = tdir = PersistentTemporaryDirectory('_arcv_') else: self.path = root diff --git a/src/calibre/test_build.py b/src/calibre/test_build.py index fd9a36d..130d08d 100644 --- a/src/calibre/test_build.py +++ b/src/calibre/test_build.py @@ -102,11 +102,6 @@ def test_imaging(): raise RuntimeError('PIL choked!') print ('PIL OK!') -def test_unrar(): - from calibre.utils.unrar import test_basic - test_basic() - print ('Unrar OK!') - def test_ssl(): import ssl ssl @@ -146,7 +141,6 @@ def test(): test_ssl() test_sqlite() test_imaging() - test_unrar() test_icu() test_woff() test_qt()