File: 0002-Avoid-timestamps-in-gzip-compressed-file-and-use-com.patch

package info (click to toggle)
pdfminer 20221105%2Bdfsg-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 16,580 kB
  • sloc: python: 19,610; xml: 360; makefile: 69; sh: 27
file content (47 lines) | stat: -rw-r--r-- 1,553 bytes parent folder | download | duplicates (2)
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