From 261c7769b869bfc34b69b960b75a20f944ff28bb Mon Sep 17 00:00:00 2001 From: Marco Feuerstein Date: Tue, 27 Jun 2023 21:25:11 +0200 Subject: [PATCH 1/3] Replace static list of supported file extensions with the actually supported ones. --- port/PyAssimp/pyassimp/core.py | 13 ++++++++++ port/PyAssimp/pyassimp/formats.py | 41 ------------------------------- 2 files changed, 13 insertions(+), 41 deletions(-) delete mode 100644 port/PyAssimp/pyassimp/formats.py diff --git a/port/PyAssimp/pyassimp/core.py b/port/PyAssimp/pyassimp/core.py index edde8b29a..af5138581 100644 --- a/port/PyAssimp/pyassimp/core.py +++ b/port/PyAssimp/pyassimp/core.py @@ -390,6 +390,19 @@ def export_blob(scene, raise AssimpError('Could not export scene to blob!') return exportBlobPtr +def available_formats(): + """ + Return a list of file format extensions supported to import. + + Returns + --------- + A list of upper-case file extensions, e.g. [3DS, OBJ] + """ + from ctypes import byref + extension_list = structs.String() + _assimp_lib.dll.aiGetExtensionList(byref(extension_list)) + return [e[2:].upper() for e in str(extension_list.data, "utf-8").split(";") if e] + def _finalize_texture(tex, target): setattr(target, "achformathint", tex.achFormatHint) if numpy: diff --git a/port/PyAssimp/pyassimp/formats.py b/port/PyAssimp/pyassimp/formats.py deleted file mode 100644 index 5d454e5b7..000000000 --- a/port/PyAssimp/pyassimp/formats.py +++ /dev/null @@ -1,41 +0,0 @@ -FORMATS = ["CSM", - "LWS", - "B3D", - "COB", - "PLY", - "IFC", - "OFF", - "SMD", - "IRRMESH", - "3D", - "DAE", - "MDL", - "HMP", - "TER", - "WRL", - "XML", - "NFF", - "AC", - "OBJ", - "3DS", - "STL", - "IRR", - "Q3O", - "Q3D", - "MS3D", - "Q3S", - "ZGL", - "MD2", - "X", - "BLEND", - "XGL", - "MD5MESH", - "MAX", - "LXO", - "DXF", - "BVH", - "LWO", - "NDO"] - -def available_formats(): - return FORMATS From 59f262016411bb3188baea2b05a2bb616290b07f Mon Sep 17 00:00:00 2001 From: Marco Feuerstein Date: Wed, 28 Jun 2023 08:20:49 +0200 Subject: [PATCH 2/3] Remove unneeded check for empty extension. --- port/PyAssimp/pyassimp/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/port/PyAssimp/pyassimp/core.py b/port/PyAssimp/pyassimp/core.py index af5138581..690a34e59 100644 --- a/port/PyAssimp/pyassimp/core.py +++ b/port/PyAssimp/pyassimp/core.py @@ -401,7 +401,7 @@ def available_formats(): from ctypes import byref extension_list = structs.String() _assimp_lib.dll.aiGetExtensionList(byref(extension_list)) - return [e[2:].upper() for e in str(extension_list.data, "utf-8").split(";") if e] + return [e[2:].upper() for e in str(extension_list.data, "utf-8").split(";")] def _finalize_texture(tex, target): setattr(target, "achformathint", tex.achFormatHint) From b2cad5c58deb5eed413c9a6a34f53911c0818d95 Mon Sep 17 00:00:00 2001 From: Marco Feuerstein Date: Thu, 29 Jun 2023 14:56:11 +0200 Subject: [PATCH 3/3] Use file system encoding. --- port/PyAssimp/pyassimp/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/port/PyAssimp/pyassimp/core.py b/port/PyAssimp/pyassimp/core.py index 690a34e59..c7ceaa9cd 100644 --- a/port/PyAssimp/pyassimp/core.py +++ b/port/PyAssimp/pyassimp/core.py @@ -401,7 +401,7 @@ def available_formats(): from ctypes import byref extension_list = structs.String() _assimp_lib.dll.aiGetExtensionList(byref(extension_list)) - return [e[2:].upper() for e in str(extension_list.data, "utf-8").split(";")] + return [e[2:].upper() for e in str(extension_list.data, sys.getfilesystemencoding()).split(";")] def _finalize_texture(tex, target): setattr(target, "achformathint", tex.achFormatHint)