Skip to content

Commit

Permalink
use split_extension helper in load_path
Browse files Browse the repository at this point in the history
  • Loading branch information
mikedh committed Nov 20, 2024
1 parent 48f0b50 commit 3019b16
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions trimesh/path/exchange/load.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os

from ... import util
from ...exchange.ply import load_ply
Expand Down Expand Up @@ -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
Expand All @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion trimesh/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3019b16

Please sign in to comment.