details: https://code.tryton.org/relatorio/commit/b598acb66d98
branch: default
user: Cédric Krier <[email protected]>
date: Thu Jun 11 12:14:32 2026 +0200
description:
Replace python-magic dependency by puremagic
Closes #77
diffstat:
CHANGELOG | 1 +
pyproject.toml | 2 +-
relatorio/templates/opendocument.py | 8 ++------
3 files changed, 4 insertions(+), 7 deletions(-)
diffs (44 lines):
diff -r dbb1d2bd208e -r b598acb66d98 CHANGELOG
--- a/CHANGELOG Sat Mar 21 18:50:21 2026 +0100
+++ b/CHANGELOG Thu Jun 11 12:14:32 2026 +0200
@@ -1,3 +1,4 @@
+* Replace python-magic dependency by puremagic
* Remove support for chart template
* Remove support for PDF
diff -r dbb1d2bd208e -r b598acb66d98 pyproject.toml
--- a/pyproject.toml Sat Mar 21 18:50:21 2026 +0100
+++ b/pyproject.toml Thu Jun 11 12:14:32 2026 +0200
@@ -30,7 +30,7 @@
[project.optional-dependencies]
fodt = [
- 'python-magic',
+ 'puremagic',
]
[project.urls]
diff -r dbb1d2bd208e -r b598acb66d98 relatorio/templates/opendocument.py
--- a/relatorio/templates/opendocument.py Sat Mar 21 18:50:21 2026 +0100
+++ b/relatorio/templates/opendocument.py Thu Jun 11 12:14:32 2026 +0200
@@ -986,18 +986,14 @@
def extract_images(child, namespaces, start=0):
"Extract draw:image with binary-data and replace by href"
- import magic
+ import puremagic
images = []
for i, image in enumerate(
child.xpath('//draw:image', namespaces=namespaces), start):
binary_data, = image.xpath(
'./office:binary-data', namespaces=namespaces)
data = base64.b64decode(binary_data.text)
- 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
+ mime_type = puremagic.from_string(data, mime=True)
name = 'Pictures/image%s%s' % (
i, mimetypes.guess_extension(mime_type))
image.remove(binary_data)