Added tags to capture metadata
This commit is contained in:
parent
4e985fe80d
commit
7a72b45b29
2 changed files with 14 additions and 2 deletions
|
|
@ -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))}
|
||||
|
|
|
|||
|
|
@ -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])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue