fix removement of instances

This commit is contained in:
Jakub Trllo 2022-10-19 10:42:09 +02:00
parent 6b5f0afdba
commit 9a9aeef3ac

View file

@ -139,6 +139,26 @@ class TVPaintHost(HostBase, IWorkfileHost, ILoadHost):
log.info("Setting up project...")
set_context_settings()
def remove_instance(self, instance):
"""Remove instance from current workfile metadata.
Implementation for Subset manager tool.
"""
current_instances = get_workfile_metadata(SECTION_NAME_INSTANCES)
instance_id = instance.get("uuid")
found_idx = None
if instance_id:
for idx, _inst in enumerate(current_instances):
if _inst["uuid"] == instance_id:
found_idx = idx
break
if found_idx is None:
return
current_instances.pop(found_idx)
write_instances(current_instances)
def application_exit(self):
"""Logic related to TimerManager.
@ -421,23 +441,6 @@ def save_current_workfile_context(context):
return write_workfile_metadata(SECTION_NAME_CONTEXT, context)
def remove_instance(instance):
"""Remove instance from current workfile metadata."""
current_instances = get_workfile_metadata(SECTION_NAME_INSTANCES)
instance_id = instance.get("uuid")
found_idx = None
if instance_id:
for idx, _inst in enumerate(current_instances):
if _inst["uuid"] == instance_id:
found_idx = idx
break
if found_idx is None:
return
current_instances.pop(found_idx)
write_instances(current_instances)
def list_instances():
"""List all created instances from current workfile."""
return get_workfile_metadata(SECTION_NAME_INSTANCES)