1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
From: Emmanuel Arias <eamanu@yaerobi.com>
Date: Sat, 8 Aug 2020 20:36:57 -0300
Subject: Avoid timestamps in gzip-compressed file and use compressionlevel=9
to reduce data size
Forwarded: https://github.com/euske/pdfminer/pull/119
Updated patch.
---
tools/conv_cmap.py | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/tools/conv_cmap.py b/tools/conv_cmap.py
index e265ee4..fdfba06 100755
--- a/tools/conv_cmap.py
+++ b/tools/conv_cmap.py
@@ -186,17 +186,22 @@ def main(argv):
for enc in converter.get_encs():
fname = "%s.pickle.gz" % enc
path = os.path.join(outdir, fname)
- print("writing: %r..." % path)
- fp = gzip.open(path, "wb")
- converter.dump_cmap(fp, enc)
- fp.close()
+ print('writing: %r...' % path)
+ with open(path, 'wb') as fp:
+ # with statement support for GzipFile is available only from Python
+ # 2.7
+ fgz = gzip.GzipFile('', 'wb', 9, fp, 0.)
+ converter.dump_cmap(fgz, enc)
+ fgz.close()
fname = "to-unicode-%s.pickle.gz" % regname
path = os.path.join(outdir, fname)
- print("writing: %r..." % path)
- fp = gzip.open(path, "wb")
- converter.dump_unicodemap(fp)
- fp.close()
+ print('writing: %r...' % path)
+ with open(path, 'wb') as fp:
+ # with statement support for GzipFile is available only from Python
+ # 2.7
+ fgz = gzip.GzipFile('', 'wb', 9, fp, 0.)
+ converter.dump_unicodemap(fgz)
return
|