mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
hiero: improving management of versions
This commit is contained in:
parent
3ee386543b
commit
756bb9d85a
2 changed files with 20 additions and 11 deletions
|
|
@ -11,6 +11,7 @@ import functools
|
|||
import warnings
|
||||
import json
|
||||
import ast
|
||||
import secrets
|
||||
import shutil
|
||||
import hiero
|
||||
|
||||
|
|
@ -350,6 +351,8 @@ def set_track_openpype_tag(track, data=None):
|
|||
Returns:
|
||||
hiero.core.Tag
|
||||
"""
|
||||
hash = secrets.token_hex(nbytes=4)
|
||||
|
||||
data = data or {}
|
||||
|
||||
# basic Tag's attribute
|
||||
|
|
@ -367,7 +370,10 @@ def set_track_openpype_tag(track, data=None):
|
|||
tag = tags.update_tag(_tag, tag_data)
|
||||
else:
|
||||
# if pype tag available then update with input data
|
||||
tag = tags.create_tag(self.pype_tag_name, tag_data)
|
||||
tag = tags.create_tag(
|
||||
"{}_{}".format(self.pype_tag_name, hash),
|
||||
tag_data
|
||||
)
|
||||
# add it to the input track item
|
||||
track.addTag(tag)
|
||||
|
||||
|
|
@ -390,7 +396,7 @@ def get_track_openpype_tag(track):
|
|||
return None
|
||||
for tag in _tags:
|
||||
# return only correct tag defined by global name
|
||||
if tag.name() == self.pype_tag_name:
|
||||
if self.pype_tag_name in tag.name():
|
||||
return tag
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -201,6 +201,15 @@ def parse_container(item, validate=True):
|
|||
return data_to_container(item, _data)
|
||||
|
||||
|
||||
def _update_container_data(container, data):
|
||||
for key in container:
|
||||
try:
|
||||
container[key] = data[key]
|
||||
except KeyError:
|
||||
pass
|
||||
return container
|
||||
|
||||
|
||||
def update_container(item, data=None):
|
||||
"""Update container data to input track_item or track's
|
||||
openpype tag.
|
||||
|
|
@ -214,15 +223,9 @@ def update_container(item, data=None):
|
|||
bool: True if container was updated correctly
|
||||
|
||||
"""
|
||||
def update_container_data(container, data):
|
||||
for key in container:
|
||||
try:
|
||||
container[key] = data[key]
|
||||
except KeyError:
|
||||
pass
|
||||
return container
|
||||
|
||||
data = data or {}
|
||||
data = deepcopy(data)
|
||||
|
||||
if type(item) == hiero.core.VideoTrack:
|
||||
# form object data for test
|
||||
|
|
@ -236,14 +239,14 @@ def update_container(item, data=None):
|
|||
container = deepcopy(container)
|
||||
|
||||
# update data in container
|
||||
updated_container = update_container_data(container, data)
|
||||
updated_container = _update_container_data(container, data)
|
||||
# merge updated container back to containers
|
||||
containers.update({object_name: updated_container})
|
||||
|
||||
return bool(lib.set_track_openpype_tag(item, containers))
|
||||
else:
|
||||
container = lib.get_trackitem_openpype_data(item)
|
||||
updated_container = update_container_data(container, data)
|
||||
updated_container = _update_container_data(container, data)
|
||||
|
||||
log.info("Updating container: `{}`".format(item.name()))
|
||||
return bool(lib.set_trackitem_openpype_tag(item, updated_container))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue