From 10b7fa756b892bcfebeae420ecd2237aa0b8fa81 Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Fri, 27 Oct 2023 10:19:50 +0200 Subject: [PATCH] more pathlib support --- rerun_py/rerun_sdk/rerun/archetypes/asset3d_ext.py | 6 ++---- rerun_py/rerun_sdk/rerun/sinks.py | 5 +++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/rerun_py/rerun_sdk/rerun/archetypes/asset3d_ext.py b/rerun_py/rerun_sdk/rerun/archetypes/asset3d_ext.py index e9477fa03e4f..4ec1d07ac689 100644 --- a/rerun_py/rerun_sdk/rerun/archetypes/asset3d_ext.py +++ b/rerun_py/rerun_sdk/rerun/archetypes/asset3d_ext.py @@ -10,12 +10,10 @@ from ..components import MediaType -def guess_media_type(path: str) -> MediaType | None: - from pathlib import Path - +def guess_media_type(path: str | pathlib.Path) -> MediaType | None: from ..components import MediaType - ext = Path(path).suffix.lower() + ext = pathlib.Path(path).suffix.lower() if ext == ".glb": return MediaType.GLB elif ext == ".gltf": diff --git a/rerun_py/rerun_sdk/rerun/sinks.py b/rerun_py/rerun_sdk/rerun/sinks.py index 72ea70363e58..3c789bf7214f 100644 --- a/rerun_py/rerun_sdk/rerun/sinks.py +++ b/rerun_py/rerun_sdk/rerun/sinks.py @@ -1,6 +1,7 @@ from __future__ import annotations import logging +import pathlib import socket import rerun_bindings as bindings # type: ignore[attr-defined] @@ -42,7 +43,7 @@ def connect( _connect = connect # we need this because Python scoping is horrible -def save(path: str, recording: RecordingStream | None = None) -> None: +def save(path: str | pathlib.Path, recording: RecordingStream | None = None) -> None: """ Stream all log-data to a file. @@ -64,7 +65,7 @@ def save(path: str, recording: RecordingStream | None = None) -> None: return recording = RecordingStream.to_native(recording) - bindings.save(path=path, recording=recording) + bindings.save(path=str(path), recording=recording) def disconnect(recording: RecordingStream | None = None) -> None: