Skip to content

Commit c6b1f94

Browse files
committed
Fix ID retrieval
1 parent 1d29eb7 commit c6b1f94

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

simvue/api/objects/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,10 +310,10 @@ def ids(
310310
"""Retrieve a list of all object identifiers"""
311311
_class_instance = cls(_read_only=True, _local=True)
312312
_count: int = 0
313-
for _data in cls._get_all_objects(offset):
313+
for response in cls._get_all_objects(offset):
314314
if count and _count > count:
315315
return
316-
if _data.get("data") is None:
316+
if (_data := response.get("data")) is None:
317317
raise RuntimeError(
318318
f"Expected key 'data' for retrieval of {_class_instance.__class__.__name__.lower()}s"
319319
)

simvue/client.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,10 @@ def _get_folder_id_from_path(self, path: str) -> str | None:
333333
"""
334334
_ids = Folder.ids(filters=json.dumps([f"path == {path}"]))
335335

336-
return _ids[0] if _ids else None
336+
try:
337+
return next(_ids)
338+
except StopIteration:
339+
return None
337340

338341
@prettify_pydantic
339342
@pydantic.validate_call

0 commit comments

Comments
 (0)