diff --git a/openflexure_microscope/api/v1/blueprints/camera/capture.py b/openflexure_microscope/api/v1/blueprints/camera/capture.py index 7f03800a..f30fcc96 100644 --- a/openflexure_microscope/api/v1/blueprints/camera/capture.py +++ b/openflexure_microscope/api/v1/blueprints/camera/capture.py @@ -186,7 +186,6 @@ class CaptureAPI(MicroscopeView): # Get capture state capture_metadata = capture_obj.state - # TODO: Tidy up adding URI to state # Add API routes to returned state uri_dict = { 'uri': {'state': '{}'.format(url_for('.capture', capture_id=capture_obj.id))} diff --git a/openflexure_microscope/camera/capture.py b/openflexure_microscope/camera/capture.py index e9185718..5fc6a90b 100644 --- a/openflexure_microscope/camera/capture.py +++ b/openflexure_microscope/camera/capture.py @@ -83,7 +83,9 @@ class CaptureObject(object): self.folder = folder # Dictionary for storing custom metadata - self._metadata = {} + self._metadata = { + 'tags': [] + } # Initialise the capture stream self.initialise_capture(create_metadata_file=create_metadata_file) @@ -199,6 +201,17 @@ class CaptureObject(object): else: return False + # HANDLE TAGS + def put_tag(self, tag: str): + if not tag in self._metadata['tags']: + self._metadata['tags'].append(tag) + + def delete_tag(self, tag: str): + if tag in self._metadata['tags']: + self._metadata['tags'] = [new_tag for new_tag in self._metadata['tags'] if new_tag != tag] + + # HANDLE METADATA + @property def metadata_file(self) -> str: return "{}.yaml".format(os.path.splitext(self.file)[0])