Fixed finding captures by UUID
This commit is contained in:
parent
0f16c5c894
commit
bf9a1e358e
2 changed files with 15 additions and 5 deletions
|
|
@ -9,7 +9,7 @@ import logging
|
||||||
from abc import ABCMeta, abstractmethod
|
from abc import ABCMeta, abstractmethod
|
||||||
|
|
||||||
from .capture import CaptureObject
|
from .capture import CaptureObject
|
||||||
from openflexure_microscope.utilities import entry_by_id
|
from openflexure_microscope.utilities import entry_by_uuid
|
||||||
from openflexure_microscope.common.labthings_core.lock import StrictLock
|
from openflexure_microscope.common.labthings_core.lock import StrictLock
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -250,11 +250,11 @@ class BaseCamera(metaclass=ABCMeta):
|
||||||
|
|
||||||
def image_from_id(self, image_id):
|
def image_from_id(self, image_id):
|
||||||
"""Return an image StreamObject with a matching ID."""
|
"""Return an image StreamObject with a matching ID."""
|
||||||
return entry_by_id(image_id, self.images)
|
return entry_by_uuid(image_id, self.images)
|
||||||
|
|
||||||
def video_from_id(self, video_id):
|
def video_from_id(self, video_id):
|
||||||
"""Return a video StreamObject with a matching ID."""
|
"""Return a video StreamObject with a matching ID."""
|
||||||
return entry_by_id(video_id, self.videos)
|
return entry_by_uuid(video_id, self.videos)
|
||||||
|
|
||||||
# CREATING NEW CAPTURES
|
# CREATING NEW CAPTURES
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import re
|
||||||
import copy
|
import copy
|
||||||
import operator
|
import operator
|
||||||
import base64
|
import base64
|
||||||
|
from uuid import UUID
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from collections import abc
|
from collections import abc
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
|
|
@ -78,11 +79,20 @@ def filter_dict(dictionary: dict, keys: list):
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
|
||||||
def entry_by_id(entry_id: str, object_list: list):
|
def entry_by_uuid(entry_id: str, object_list: list):
|
||||||
"""Return an object from a list, if <object>.id matches id argument."""
|
"""Return an object from a list, if <object>.id matches id argument."""
|
||||||
found = None
|
found = None
|
||||||
|
if type(entry_id) == str:
|
||||||
|
converter = str
|
||||||
|
elif type(entry_id) == int:
|
||||||
|
converter = int
|
||||||
|
elif isinstance(entry_id, UUID):
|
||||||
|
converter = int
|
||||||
|
else:
|
||||||
|
raise TypeError("Argument entry_id must be a string, integer, or UUID object.")
|
||||||
for o in object_list:
|
for o in object_list:
|
||||||
if o.id == entry_id:
|
# Convert to strings (in case of UUID objects, for example)
|
||||||
|
if converter(o.id) == converter(entry_id):
|
||||||
found = o
|
found = o
|
||||||
return found
|
return found
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue