From 559109a7e8a06a4d33bfbbf2be01bdab80fbc233 Mon Sep 17 00:00:00 2001 From: DivingDuck Date: Sun, 13 Oct 2024 10:36:55 +0200 Subject: [PATCH] feat: Replace module imghdr with puremagic (#1455) `imghdr` becomes obsolete with Python 3.13 Fixes #1453 --- printrun/projectlayer.py | 6 +++--- requirements.txt | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/printrun/projectlayer.py b/printrun/projectlayer.py index 4d1da7cd..2affe32f 100644 --- a/printrun/projectlayer.py +++ b/printrun/projectlayer.py @@ -20,7 +20,7 @@ import time import zipfile import tempfile -import imghdr +import puremagic import copy import re from collections import OrderedDict @@ -756,7 +756,7 @@ def parse_3DLP_zip(self, name): for f in imagefilesOrderedDict.values(): path = os.path.join(self.image_dir.name, f) - if os.path.isfile(path) and imghdr.what(path) in accepted_image_types: + if os.path.isfile(path) and puremagic.what(path) in accepted_image_types: ol.append(path) return ol, -1, 'Bitmap' @@ -780,7 +780,7 @@ def parse_sl1(self, name): ol = [] for f in sorted(os.listdir(self.image_dir.name)): path = os.path.join(self.image_dir.name, f) - if os.path.isfile(path) and imghdr.what(path) in accepted_image_types: + if os.path.isfile(path) and puremagic.what(path) in accepted_image_types: ol.append(path) return ol, -1, 'PrusaSlicer', settings diff --git a/requirements.txt b/requirements.txt index 5b5194d5..12146cfe 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,6 +6,7 @@ pyglet >= 1.1, < 2.0 psutil (>= 2.1) lxml (>= 2.9.1) platformdirs +puremagic dbus-python >= 1.2.0 ; sys_platform == 'linux' pyobjc-framework-Cocoa ; sys_platform == 'darwin' pyreadline3 ; sys_platform == 'win32' \ No newline at end of file