Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
modified how labels in hosts enum works
Browse files Browse the repository at this point in the history
  • Loading branch information
iLLiCiTiT committed Jun 22, 2021
1 parent d7ab6bb commit a7962aa
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 25 deletions.
50 changes: 27 additions & 23 deletions openpype/settings/entities/enum_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,34 +124,38 @@ def _item_initalization(self):
self.use_empty_value = self.schema_data.get(
"use_empty_value", not self.multiselection
)
self.empty_label = (
self.schema_data.get("empty_label") or "< without host >"
)

# These are hardcoded there is not list of available host in OpenPype
self.enum_items = [
{"aftereffects": "aftereffects"},
{"blender": "blender"},
{"celaction": "celaction"},
{"fusion": "fusion"},
{"harmony": "harmony"},
{"hiero": "hiero"},
{"houdini": "houdini"},
{"maya": "maya"},
{"nuke": "nuke"},
{"photoshop": "photoshop"},
{"resolve": "resolve"},
{"tvpaint": "tvpaint"},
{"unreal": "unreal"}
custom_labels = self.schema_data.get("custom_labels") or {}

host_names = [
"aftereffects",
"blender",
"celaction",
"fusion",
"harmony",
"hiero",
"houdini",
"maya",
"nuke",
"photoshop",
"resolve",
"tvpaint",
"unreal"
]

if self.use_empty_value:
self.enum_items.insert(0, {"": self.empty_label})
host_names.insert(0, "")
# Add default label for empty value if not available
if "" not in custom_labels:
custom_labels[""] = "< without host >"

# These are hardcoded there is not list of available host in OpenPype
enum_items = []
valid_keys = set()
for item in self.enum_items or []:
valid_keys.add(tuple(item.keys())[0])
for key in host_names:
label = custom_labels.get(key, key)
valid_keys.add(key)
enum_items.append({key, label})

self.enum_items = enum_items
self.valid_keys = valid_keys

if self.multiselection:
Expand Down
7 changes: 5 additions & 2 deletions openpype/settings/entities/schemas/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,15 +276,18 @@
- enumeration of available hosts
- multiselection can be allowed with setting key `"multiselection"` to `True` (Default: `False`)
- it is possible to add empty value (represented with empty string) with setting `"use_empty_value"` to `True` (Default: `False`)
- to modify label of empty value set `"empty_label"` key with your label (Default: `< without host >`)
- it is possible to set `"custom_labels"` for host names where key `""` is empty value (Default: `{}`)
```
{
"key": "host",
"label": "Host name",
"type": "hosts-enum",
"multiselection": false,
"use_empty_value": true,
"empty_label": "N/A"
"custom_labels": {
"": "N/A",
"nuke": "Nuke"
}
}
```

Expand Down

0 comments on commit a7962aa

Please sign in to comment.