mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
hiero: wip updating effect containers
This commit is contained in:
parent
4ab8fd1a82
commit
65e7c45e94
4 changed files with 29 additions and 38 deletions
|
|
@ -9,6 +9,7 @@ import sys
|
|||
import platform
|
||||
import functools
|
||||
import warnings
|
||||
import json
|
||||
import ast
|
||||
import shutil
|
||||
import hiero
|
||||
|
|
@ -414,32 +415,11 @@ def get_track_openpype_data(track):
|
|||
tag_data = deepcopy(dict(tag.metadata()))
|
||||
|
||||
for obj_name, obj_data in tag_data.items():
|
||||
return_data[obj_name] = {}
|
||||
|
||||
# convert tag metadata to normal keys names and values to correct types
|
||||
for k, v in obj_data.items():
|
||||
|
||||
key = k.replace("tag.", "")
|
||||
|
||||
try:
|
||||
# capture exceptions which are related to strings only
|
||||
if re.match(r"^[\d]+$", v):
|
||||
value = int(v)
|
||||
elif re.match(r"^True$", v):
|
||||
value = True
|
||||
elif re.match(r"^False$", v):
|
||||
value = False
|
||||
elif re.match(r"^None$", v):
|
||||
value = None
|
||||
elif re.match(r"^[\w\d_]+$", v):
|
||||
value = v
|
||||
else:
|
||||
value = ast.literal_eval(v)
|
||||
except (ValueError, SyntaxError) as msg:
|
||||
log.warning(msg)
|
||||
value = v
|
||||
|
||||
return_data[obj_name][key] = value
|
||||
obj_name = obj_name.replace("tag.", "")
|
||||
print(obj_name)
|
||||
if obj_name in ["applieswhole", "note", "label"]:
|
||||
continue
|
||||
return_data[obj_name] = json.loads(obj_data)
|
||||
|
||||
return return_data
|
||||
|
||||
|
|
|
|||
|
|
@ -133,12 +133,13 @@ def ls():
|
|||
all_items.append(track)
|
||||
|
||||
for item in all_items:
|
||||
container = parse_container(item)
|
||||
container_data = parse_container(item)
|
||||
if isinstance(container, list):
|
||||
for _c in container:
|
||||
if isinstance(container_data, list):
|
||||
for _c in container_data:
|
||||
yield _c
|
||||
elif container:
|
||||
yield container
|
||||
elif container_data:
|
||||
yield container_data
|
||||
|
||||
|
||||
def parse_container(item, validate=True):
|
||||
|
|
@ -186,6 +187,9 @@ def parse_container(item, validate=True):
|
|||
if type(item) == hiero.core.VideoTrack:
|
||||
return_list = []
|
||||
_data = lib.get_track_openpype_data(item)
|
||||
log.info("_data: {}".format(_data))
|
||||
if not _data:
|
||||
return
|
||||
# convert the data to list and validate them
|
||||
for _, obj_data in _data.items():
|
||||
cotnainer = data_to_container(item, obj_data)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import json
|
||||
import re
|
||||
import os
|
||||
import hiero
|
||||
|
|
@ -85,17 +86,22 @@ def update_tag(tag, data):
|
|||
# get metadata key from data
|
||||
data_mtd = data.get("metadata", {})
|
||||
|
||||
# due to hiero bug we have to make sure keys which are not existent in
|
||||
# data are cleared of value by `None`
|
||||
for _mk in mtd.dict().keys():
|
||||
if _mk.replace("tag.", "") not in data_mtd.keys():
|
||||
mtd.setValue(_mk, str(None))
|
||||
# # due to hiero bug we have to make sure keys which are not existent in
|
||||
# # data are cleared of value by `None`
|
||||
# for _mk in mtd.dict().keys():
|
||||
# if _mk.replace("tag.", "") not in data_mtd.keys():
|
||||
# mtd.setValue(_mk, str(None))
|
||||
|
||||
# set all data metadata to tag metadata
|
||||
for k, v in data_mtd.items():
|
||||
for _k, _v in data_mtd.items():
|
||||
value = str(_v)
|
||||
if type(_v) == dict:
|
||||
value = json.dumps(_v)
|
||||
|
||||
# set the value
|
||||
mtd.setValue(
|
||||
"tag.{}".format(str(k)),
|
||||
str(v)
|
||||
"tag.{}".format(str(_k)),
|
||||
value
|
||||
)
|
||||
|
||||
# set note description of tag
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ class LoadEffects(load.LoaderPlugin):
|
|||
"source": version_data["source"],
|
||||
"version": vname,
|
||||
"author": version_data["author"],
|
||||
"objectName": object_name,
|
||||
"children_names": []
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue