Do not update Hierarchy tag. This needs to be explicitly manually deleted before updating.

This commit is contained in:
Toke Jepsen 2019-07-04 09:01:35 +01:00
parent 9b31031791
commit 5f3374e1e6

View file

@ -10,8 +10,6 @@ import hiero
log = Logger().get_logger(__name__, "nukestudio")
_hierarchy_orig = 'hierarchy_orig'
def create_tag(key, value):
"""
@ -39,10 +37,10 @@ def update_tag(tag, value):
value (dict): parameters of tag
"""
tag.setNote(value['note'])
tag.setIcon(str(value['icon']['path']))
tag.setNote(value["note"])
tag.setIcon(str(value["icon"]["path"]))
mtd = tag.metadata()
pres_mtd = value.get('metadata', None)
pres_mtd = value.get("metadata", None)
if pres_mtd:
[mtd.setValue("tag.{}".format(str(k)), str(v))
for k, v in pres_mtd.items()]
@ -59,7 +57,7 @@ def add_tags_from_presets():
presets = config.get_presets()
# get nukestudio tag.json from presets
nks_pres = presets['nukestudio']
nks_pres = presets["nukestudio"]
nks_pres_tags = nks_pres.get("tags", None)
# Get project task types.
@ -142,24 +140,10 @@ def add_tags_from_presets():
else:
# check if Hierarchy in name
# update Tag if already exists
tag_names = [tg.name().lower() for tg in tags]
for _t in tags:
if 'hierarchy' not in _t.name().lower():
# update only non hierarchy tags
# because hierarchy could be edited
update_tag(_t, _val)
elif _hierarchy_orig in _t.name().lower():
# if hierarchy_orig already exists just
# sync with preset
update_tag(_t, _val)
else:
# if history tag already exist then create
# backup synchronisable original Tag
if (_hierarchy_orig not in tag_names):
# create Tag obj
tag = create_tag(
_hierarchy_orig.capitalize(), _val
)
if "hierarchy" in _t.name().lower():
continue
# adding Tag to Bin
root_bin.addItem(tag)
# update only non hierarchy tags
# because hierarchy could be edited
update_tag(_t, _val)