From 8bbd389d0fbe8cf5558d987ba906587e99021433 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 3 Jun 2016 20:53:06 +0530 Subject: [PATCH] Nicer error messages for unknown compression type --- src/calibre/utils/zipfile.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/calibre/utils/zipfile.py b/src/calibre/utils/zipfile.py index 966cbef580..768d46badd 100644 --- a/src/calibre/utils/zipfile.py +++ b/src/calibre/utils/zipfile.py @@ -42,6 +42,7 @@ ZIP_MAX_COMMENT = (1 << 16) - 1 ZIP_STORED = 0 ZIP_DEFLATED = 8 # Other ZIP compression methods not supported +# For a list see: http://www.winzip.com/wz54.htm # Below are some formats and associated data for reading/writing headers using # the struct module. The names and structures of headers/records are those used @@ -721,7 +722,7 @@ class ZipFile: raise RuntimeError( "Compression requires the (missing) zlib module") else: - raise RuntimeError("That compression method is not supported") + raise RuntimeError("The compression method %s is not supported" % compression) self._allowZip64 = allowZip64 self._didModify = False @@ -1171,7 +1172,7 @@ class ZipFile: "Compression requires the (missing) zlib module") if zinfo.compress_type not in (ZIP_STORED, ZIP_DEFLATED): raise RuntimeError( - "That compression method is not supported") + "The compression method %s is not supported" % zinfo.compress_type) if zinfo.file_size > ZIP64_LIMIT: if not self._allowZip64: raise LargeZipFile("Filesize would require ZIP64 extensions")