Merge pull request #1739 from pypeclub/feature/hosts_enum

Settings Hosts enum
This commit is contained in:
Jakub Trllo 2021-06-23 10:38:01 +02:00 committed by GitHub
commit 958826d1bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 108 additions and 29 deletions

View file

@ -101,6 +101,7 @@ from .color_entity import ColorEntity
from .enum_entity import (
BaseEnumEntity,
EnumEntity,
HostsEnumEntity,
AppsEnumEntity,
ToolsEnumEntity,
TaskTypeEnumEntity,
@ -153,6 +154,7 @@ __all__ = (
"BaseEnumEntity",
"EnumEntity",
"HostsEnumEntity",
"AppsEnumEntity",
"ToolsEnumEntity",
"TaskTypeEnumEntity",

View file

@ -101,6 +101,78 @@ class EnumEntity(BaseEnumEntity):
super(EnumEntity, self).schema_validations()
class HostsEnumEntity(BaseEnumEntity):
"""Enumeration of host names.
Enum items are hardcoded in definition of the entity.
Hosts enum can have defined empty value as valid option which is
represented by empty string. Schema key to set this option is
`use_empty_value` (true/false). And to set label of empty value set
`empty_label` (string).
Enum can have single and multiselection.
NOTE:
Host name is not the same as application name. Host name defines
implementation instead of application name.
"""
schema_types = ["hosts-enum"]
def _item_initalization(self):
self.multiselection = self.schema_data.get("multiselection", True)
self.use_empty_value = self.schema_data.get(
"use_empty_value", not self.multiselection
)
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:
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 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:
self.valid_value_types = (list, )
self.value_on_not_set = []
else:
for key in valid_keys:
if self.value_on_not_set is NOT_SET:
self.value_on_not_set = key
break
self.valid_value_types = (STRING_TYPE, )
# GUI attribute
self.placeholder = self.schema_data.get("placeholder")
class AppsEnumEntity(BaseEnumEntity):
schema_types = ["apps-enum"]

View file

@ -272,6 +272,25 @@
}
```
### hosts-enum
- 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`)
- 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,
"custom_labels": {
"": "N/A",
"nuke": "Nuke"
}
}
```
## Inputs for setting value using Pure inputs
- these inputs also have required `"key"`
- attribute `"label"` is required in few conditions

View file

@ -59,10 +59,10 @@
"object_type": "text"
},
{
"type": "hosts-enum",
"key": "hosts",
"label": "Host names",
"type": "list",
"object_type": "text"
"multiselection": true
},
{
"type": "separator"

View file

@ -90,10 +90,10 @@
"object_type": "text"
},
{
"type": "hosts-enum",
"key": "hosts",
"label": "Hosts",
"type": "list",
"object_type": "text"
"multiselection": true
},
{
"type": "splitter"
@ -358,10 +358,10 @@
"object_type": "text"
},
{
"type": "hosts-enum",
"key": "hosts",
"label": "Hosts",
"type": "list",
"object_type": "text"
"multiselection": true
},
{
"type": "splitter"
@ -492,10 +492,10 @@
"object_type": "text"
},
{
"type": "hosts-enum",
"key": "hosts",
"label": "Hosts",
"type": "list",
"object_type": "text"
"multiselection": true
},
{
"key": "tasks",

View file

@ -35,10 +35,10 @@
"object_type": "text"
},
{
"type": "hosts-enum",
"key": "hosts",
"label": "Hosts",
"type": "list",
"object_type": "text"
"multiselection": true
},
{
"key": "tasks",
@ -75,10 +75,10 @@
"type": "dict",
"children": [
{
"type": "hosts-enum",
"key": "hosts",
"label": "Hosts",
"type": "list",
"object_type": "text"
"multiselection": true
},
{
"key": "tasks",

View file

@ -14,25 +14,11 @@
"roles": ["developer"]
},
{
"type": "enum",
"type": "hosts-enum",
"key": "host_name",
"label": "Host implementation",
"enum_items": [
{ "": "< without host >" },
{ "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" }
],
"multiselection": false,
"use_empty_value": true,
"roles": ["developer"]
}
]