OP-2765 - refactored imprint method

Uses id instead of full AEItem
This commit is contained in:
Petr Kalis 2022-03-03 19:31:18 +01:00
parent a27119bee4
commit ebc05e82c8
4 changed files with 14 additions and 15 deletions

View file

@ -178,7 +178,7 @@ def containerise(name,
Arguments:
name (str): Name of resulting assembly
namespace (str): Namespace under which to host container
comp (Comp): Composition to containerise
comp (AEItem): Composition to containerise
context (dict): Asset information
loader (str, optional): Name of loader used to produce this container.
suffix (str, optional): Suffix of container, defaults to `_CON`.
@ -197,7 +197,7 @@ def containerise(name,
}
stub = get_stub()
stub.imprint(comp, data)
stub.imprint(comp.id, data)
return comp
@ -254,8 +254,8 @@ def remove_instance(instance):
stub.remove_instance(inst_id)
if instance.members:
item = stub.get_item(instance.members[0])
if instance.get("members"):
item = stub.get_item(instance["members"][0])
if item:
stub.rename_item(item.id,
item.name.replace(stub.PUBLISH_ICON, ''))

View file

@ -111,11 +111,11 @@ class AfterEffectsServerStub():
self.log.debug("Couldn't find layer metadata")
def imprint(self, item, data, all_items=None, items_meta=None):
def imprint(self, item_id, data, all_items=None, items_meta=None):
"""
Save item metadata to Label field of metadata of active document
Args:
item (AEItem):
item_id (int|str): id of FootageItem or instance_id for workfiles
data(string): json representation for single layer
all_items (list of item): for performance, could be
injected for usage in loop, if not, single call will be
@ -134,8 +134,8 @@ class AfterEffectsServerStub():
for item_meta in items_meta:
if ((item_meta.get('members') and
str(item.id) == str(item_meta.get('members')[0])) or
item_meta.get("instance_id") == item.id):
str(item_id) == str(item_meta.get('members')[0])) or
item_meta.get("instance_id") == item_id):
is_new = False
if data:
item_meta.update(data)

View file

@ -91,7 +91,7 @@ class BackgroundLoader(AfterEffectsLoader):
container["namespace"] = comp_name
container["members"] = comp.members
stub.imprint(comp, container)
stub.imprint(comp.id, container)
def remove(self, container):
"""
@ -100,10 +100,9 @@ class BackgroundLoader(AfterEffectsLoader):
Args:
container (dict): container to be removed - used to get layer_id
"""
print("!!!! container:: {}".format(container))
stub = self.get_stub()
layer = container.pop("layer")
stub.imprint(layer, {})
stub.imprint(layer.id, {})
stub.delete_item(layer.id)
def switch(self, container, representation):

View file

@ -96,9 +96,9 @@ class FileLoader(AfterEffectsLoader):
# with aftereffects.maintained_selection(): # TODO
stub.replace_item(layer.id, path, stub.LOADED_ICON + layer_name)
stub.imprint(
layer, {"representation": str(representation["_id"]),
"name": context["subset"],
"namespace": layer_name}
layer.id, {"representation": str(representation["_id"]),
"name": context["subset"],
"namespace": layer_name}
)
def remove(self, container):
@ -109,7 +109,7 @@ class FileLoader(AfterEffectsLoader):
"""
stub = self.get_stub()
layer = container.pop("layer")
stub.imprint(layer, {})
stub.imprint(layer.id, {})
stub.delete_item(layer.id)
def switch(self, container, representation):