From 15dff9ce4e1ffed29ba4a2feadfcdb6bed00bcad Mon Sep 17 00:00:00 2001 From: Ozzieisaacs Date: Tue, 28 Apr 2020 20:32:10 +0200 Subject: [PATCH] Changed unrar to rarfile Removed unused pypdf dependency in setup --- comicapi/comicarchive.py | 27 ++++++++++----------------- setup.py | 8 ++++---- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/comicapi/comicarchive.py b/comicapi/comicarchive.py index 220406e..a477a18 100755 --- a/comicapi/comicarchive.py +++ b/comicapi/comicarchive.py @@ -28,10 +28,10 @@ import shutil from natsort import natsorted try: - from unrar import rarfile - from unrar import unrarlib - import unrar.constants - from unrar import constants + import rarfile + #from unrar import unrarlib + #import unrar.constants + #from unrar import constants rarsupport = True except ImportError: rarsupport = False @@ -39,7 +39,7 @@ import ctypes import io -if rarsupport: +'''if rarsupport: class OpenableRarFile(rarfile.RarFile): def open(self, member): #print "opening %s..." % member @@ -75,7 +75,7 @@ if rarsupport: self._close(handle) if not found: raise KeyError('There is no item named %r in the archive' % member) - return b''.join(buf) + return b''.join(buf)''' # if platform.system() == "Windows": @@ -372,17 +372,9 @@ if rarsupport: while tries < 7: try: tries = tries + 1 - #tmp_folder = tempfile.mkdtemp() - #tmp_file = os.path.join(tmp_folder, archive_file) - #rarc.extract(archive_file, tmp_folder) - data = rarc.open(archive_file) - #data = open(tmp_file).read() + data = rarc.read(archive_file) entries = [(rarc.getinfo(archive_file), data)] - #shutil.rmtree(tmp_folder, ignore_errors=True) - - #entries = rarc.read_files( archive_file ) - if entries[0][0].file_size != len(entries[0][1]): errMsg = u"readArchiveFile(): [file is not expected size: {0} vs {1}] {2}:{3} [attempt # {4}]".format( entries[0][0].file_size, len(entries[0][1]), self.path, @@ -502,7 +494,8 @@ if rarsupport: try: tries = tries + 1 #rarc = UnRAR2.RarFile( self.path ) - rarc = OpenableRarFile(self.path) + rarc = rarfile.RarFile(self.path) + #rarc = OpenableRarFile(self.path) except (OSError, IOError) as e: errMsg = u"getRARObj(): [{0}] {1} attempt#{2}".format( @@ -903,7 +896,7 @@ class ComicArchive: # k = os.path.join(os.path.split(k)[0], "z" + basename) return k.lower() - files = natsorted(files, key=keyfunc, signed=False) + files = natsorted(files, key=keyfunc) #, signed=False) # make a sub-list of image files self.page_list = [] diff --git a/setup.py b/setup.py index fad7a56..b29c707 100644 --- a/setup.py +++ b/setup.py @@ -1,15 +1,15 @@ from setuptools import setup setup( name = 'comicapi', - version = '2.0', + version = '2.1', description = 'Comic archive (cbr/cbz) and metadata utilities. Extracted from the comictagger project.', author = 'Iris W', packages = ['comicapi'], - install_requires = ['natsort>=3.5.2', 'pypdf2>=1.26'], + install_requires = ['natsort>=3.5.2'], extras_require = { - 'CBR': ['unrar==0.3'] + 'CBR': ['rarfile==2.7'] }, python_requires = '>=2.7.0', - url = 'https://github.com/wildthyme/comicapi', + url = 'https://github.com/OzzieIsaacs/comicapi', classifiers = ['License :: OSI Approved :: Apache Software License 2.0 (Apache-2.0)'] )