summarylogtreecommitdiffstats
path: root/ebec469f4baa.diff
blob: 1e228d5ac64292e77c6bde7f5094570434aeae94 (plain)
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

# HG changeset patch
# User Cédric Krier <ced@b2ck.com>
# Date 1570791867 -7200
# Node ID ebec469f4baa9523522bb5a81113bf9a381bfc87
# Parent  e1b70835bc9eaa1af25f390ead9dee50c8fbf8fe
Support file-magic as fallback to python-magic

bug53

diff -r e1b70835bc9e -r ebec469f4baa CHANGES
--- a/CHANGES	Mon Jul 29 16:12:32 2019 +0200
+++ b/CHANGES	Fri Oct 11 13:04:27 2019 +0200
@@ -1,3 +1,5 @@
+* Support file-magic as fallback to python-magic
+
 0.9.0 - 20190729
 * Support out parameter of render
 * Write opendocument stream directly to the ZipFile
diff -r e1b70835bc9e -r ebec469f4baa relatorio/templates/opendocument.py
--- a/relatorio/templates/opendocument.py	Mon Jul 29 16:12:32 2019 +0200
+++ b/relatorio/templates/opendocument.py	Fri Oct 11 13:04:27 2019 +0200
@@ -950,7 +950,11 @@
         binary_data, = image.xpath(
             './office:binary-data', namespaces=namespaces)
         data = base64.b64decode(binary_data.text)
-        mime_type = magic.from_buffer(data, mime=True)
+        if hasattr(magic, 'from_buffer'):
+            mime_type = magic.from_buffer(data, mime=True)
+        else:
+            # Not python-magic but file-magic
+            mime_type = magic.detect_from_content(data).mime_type
         name = 'Pictures/image%s%s' % (
             i, mimetypes.guess_extension(mime_type))
         image.remove(binary_data)