diff --git a/trimesh/path/exchange/load.py b/trimesh/path/exchange/load.py index b6b28fc30..3eb139761 100644 --- a/trimesh/path/exchange/load.py +++ b/trimesh/path/exchange/load.py @@ -1,4 +1,3 @@ -import os from ... import util from ...exchange.ply import load_ply @@ -34,9 +33,14 @@ def load_path(file_obj, file_type=None, **kwargs): # avoid a circular import from ...exchange.load import load_kwargs + if isinstance(file_type, str): + # get the file type from the extension + file_type = util.split_extension(file_type) + # record how long we took tic = util.now() + if isinstance(file_obj, Path): # we have been passed a Path file_object so # do nothing and return the passed file_object @@ -52,7 +56,7 @@ def load_path(file_obj, file_type=None, **kwargs): # strings passed are evaluated as file file_objects with open(file_obj, "rb") as f: # get the file type from the extension - file_type = os.path.splitext(file_obj)[-1][1:].lower() + file_type = util.split_extension(file_obj) if file_type == "ply": # we cannot register this exporter to path_loaders since this is already reserved by TriMesh in ply format in trimesh.load() kwargs.update(load_ply(f, file_type=file_type)) diff --git a/trimesh/util.py b/trimesh/util.py index b008e4f1d..38fdbd7b2 100644 --- a/trimesh/util.py +++ b/trimesh/util.py @@ -1906,7 +1906,7 @@ def compress(info, **kwargs): return compressed -def split_extension(file_name, special=None): +def split_extension(file_name, special=None) -> str: """ Find the file extension of a file name, including support for special case multipart file extensions (like .tar.gz)