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

Commit

Permalink
Merge pull request #1739 from pypeclub/feature/hosts_enum
Browse files Browse the repository at this point in the history
Settings Hosts enum
  • Loading branch information
iLLiCiTiT authored Jun 23, 2021
2 parents a79af86 + 9cbb102 commit 958826d
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 29 deletions.
2 changes: 2 additions & 0 deletions openpype/settings/entities/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
from .enum_entity import (
BaseEnumEntity,
EnumEntity,
HostsEnumEntity,
AppsEnumEntity,
ToolsEnumEntity,
TaskTypeEnumEntity,
Expand Down Expand Up @@ -153,6 +154,7 @@

"BaseEnumEntity",
"EnumEntity",
"HostsEnumEntity",
"AppsEnumEntity",
"ToolsEnumEntity",
"TaskTypeEnumEntity",
Expand Down
72 changes: 72 additions & 0 deletions openpype/settings/entities/enum_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,78 @@ def schema_validations(self):
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"]

Expand Down
19 changes: 19 additions & 0 deletions openpype/settings/entities/schemas/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@
"object_type": "text"
},
{
"type": "hosts-enum",
"key": "hosts",
"label": "Host names",
"type": "list",
"object_type": "text"
"multiselection": true
},
{
"type": "separator"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@
"object_type": "text"
},
{
"type": "hosts-enum",
"key": "hosts",
"label": "Hosts",
"type": "list",
"object_type": "text"
"multiselection": true
},
{
"type": "splitter"
Expand Down Expand Up @@ -358,10 +358,10 @@
"object_type": "text"
},
{
"type": "hosts-enum",
"key": "hosts",
"label": "Hosts",
"type": "list",
"object_type": "text"
"multiselection": true
},
{
"type": "splitter"
Expand Down Expand Up @@ -492,10 +492,10 @@
"object_type": "text"
},
{
"type": "hosts-enum",
"key": "hosts",
"label": "Hosts",
"type": "list",
"object_type": "text"
"multiselection": true
},
{
"key": "tasks",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
"object_type": "text"
},
{
"type": "hosts-enum",
"key": "hosts",
"label": "Hosts",
"type": "list",
"object_type": "text"
"multiselection": true
},
{
"key": "tasks",
Expand Down Expand Up @@ -75,10 +75,10 @@
"type": "dict",
"children": [
{
"type": "hosts-enum",
"key": "hosts",
"label": "Hosts",
"type": "list",
"object_type": "text"
"multiselection": true
},
{
"key": "tasks",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}
]

0 comments on commit 958826d

Please sign in to comment.