mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 18:24:30 -04:00
DRYer
This commit is contained in:
parent
807ba2fe8b
commit
a2e06b5132
@ -197,10 +197,9 @@ class Adder(QObject):
|
||||
def extract(source):
|
||||
tdir = tempfile.mkdtemp(suffix='_archive', dir=self.tdir)
|
||||
if source.lower().endswith('.zip'):
|
||||
from calibre.utils.zipfile import ZipFile
|
||||
from calibre.utils.zipfile import extractall
|
||||
try:
|
||||
with ZipFile(source) as zf:
|
||||
zf.extractall(tdir)
|
||||
extractall(source, tdir)
|
||||
except Exception:
|
||||
prints('Corrupt ZIP file, trying to use local headers')
|
||||
from calibre.utils.localunzip import extractall
|
||||
|
@ -1624,6 +1624,11 @@ class PyZipFile(ZipFile):
|
||||
return (fname, archivename)
|
||||
|
||||
|
||||
def extractall(source, dest):
|
||||
with ZipFile(source) as zf:
|
||||
zf.extractall(dest)
|
||||
|
||||
|
||||
def main(args=None):
|
||||
import textwrap
|
||||
USAGE=textwrap.dedent("""\
|
||||
|
Loading…
x
Reference in New Issue
Block a user