mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
Merge pull request #69 from ynput/enhancement/OP-8205_Hiero-use-AYON-settings
Hiero: Use AYON settings
This commit is contained in:
commit
7057db797c
3 changed files with 39 additions and 38 deletions
|
|
@ -54,25 +54,36 @@ class LoadClip(phiero.SequenceLoader):
|
|||
|
||||
plugin_name = cls.__name__
|
||||
|
||||
plugin_settings = None
|
||||
# Look for plugin settings in host specific settings
|
||||
if plugin_name in plugin_type_settings:
|
||||
plugin_settings = plugin_type_settings[plugin_name]
|
||||
|
||||
plugin_settings = plugin_type_settings.get(plugin_name)
|
||||
if not plugin_settings:
|
||||
return
|
||||
|
||||
print(">>> We have preset for {}".format(plugin_name))
|
||||
for option, value in plugin_settings.items():
|
||||
if option == "representations":
|
||||
continue
|
||||
|
||||
if option == "product_types":
|
||||
# TODO remove the key conversion when loaders can filter by
|
||||
# product types
|
||||
# convert 'product_types' to 'families'
|
||||
option = "families"
|
||||
|
||||
elif option == "clip_name_template":
|
||||
# TODO remove the formatting replacement
|
||||
value = (
|
||||
value
|
||||
.replace("{folder[name]}", "{asset}")
|
||||
.replace("{product[name]}", "{subset}")
|
||||
)
|
||||
|
||||
if option == "enabled" and value is False:
|
||||
print(" - is disabled by preset")
|
||||
elif option == "representations":
|
||||
continue
|
||||
else:
|
||||
print(" - setting `{}`: `{}`".format(option, value))
|
||||
setattr(cls, option, value)
|
||||
|
||||
|
||||
def load(self, context, name, namespace, options):
|
||||
# add clip name template to options
|
||||
options.update({
|
||||
|
|
|
|||
|
|
@ -319,35 +319,6 @@ def _convert_nuke_project_settings(ayon_settings, output):
|
|||
output["nuke"] = ayon_nuke
|
||||
|
||||
|
||||
def _convert_hiero_project_settings(ayon_settings, output):
|
||||
if "hiero" not in ayon_settings:
|
||||
return
|
||||
|
||||
ayon_hiero = ayon_settings["hiero"]
|
||||
|
||||
new_gui_filters = {}
|
||||
for item in ayon_hiero.pop("filters", []):
|
||||
subvalue = {}
|
||||
key = item["name"]
|
||||
for subitem in item["value"]:
|
||||
subvalue[subitem["name"]] = subitem["value"]
|
||||
new_gui_filters[key] = subvalue
|
||||
ayon_hiero["filters"] = new_gui_filters
|
||||
|
||||
ayon_load_clip = ayon_hiero["load"]["LoadClip"]
|
||||
if "product_types" in ayon_load_clip:
|
||||
ayon_load_clip["families"] = ayon_load_clip.pop("product_types")
|
||||
|
||||
ayon_load_clip = ayon_hiero["load"]["LoadClip"]
|
||||
ayon_load_clip["clip_name_template"] = (
|
||||
ayon_load_clip["clip_name_template"]
|
||||
.replace("{folder[name]}", "{asset}")
|
||||
.replace("{product[name]}", "{subset}")
|
||||
)
|
||||
|
||||
output["hiero"] = ayon_hiero
|
||||
|
||||
|
||||
def _convert_royalrender_project_settings(ayon_settings, output):
|
||||
if "royalrender" not in ayon_settings:
|
||||
return
|
||||
|
|
@ -365,7 +336,6 @@ def convert_project_settings(ayon_settings, default_settings):
|
|||
output = {}
|
||||
|
||||
_convert_nuke_project_settings(ayon_settings, output)
|
||||
_convert_hiero_project_settings(ayon_settings, output)
|
||||
|
||||
_convert_royalrender_project_settings(ayon_settings, output)
|
||||
|
||||
|
|
|
|||
|
|
@ -202,19 +202,39 @@ class Controller(QtCore.QObject):
|
|||
def current_state(self):
|
||||
return self._current_state
|
||||
|
||||
@staticmethod
|
||||
def _convert_filter_presets(filter_presets):
|
||||
"""Convert AYON settings presets to dictionary.
|
||||
|
||||
Returns:
|
||||
dict[str, dict[str, Any]]: Filter presets converted to dictionary.
|
||||
"""
|
||||
if not isinstance(filter_presets, list):
|
||||
return filter_presets
|
||||
|
||||
return {
|
||||
filter_preset["name"]: {
|
||||
item["name"]: item["value"]
|
||||
for item in filter_preset["value"]
|
||||
}
|
||||
for filter_preset in filter_presets
|
||||
}
|
||||
|
||||
def presets_by_hosts(self):
|
||||
# Get global filters as base
|
||||
presets = get_current_project_settings()
|
||||
if not presets:
|
||||
return {}
|
||||
|
||||
result = presets.get("core", {}).get("filters", {})
|
||||
result = {}
|
||||
hosts = pyblish.api.registered_hosts()
|
||||
for host in hosts:
|
||||
host_presets = presets.get(host, {}).get("filters")
|
||||
if not host_presets:
|
||||
continue
|
||||
|
||||
host_presets = self._convert_filter_presets(host_presets)
|
||||
|
||||
for key, value in host_presets.items():
|
||||
if value is None:
|
||||
if key in result:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue