mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 08:24:53 +01:00
Merge branch 'develop' into enhancement/remove-acre-usage
This commit is contained in:
commit
6b103eeb61
18 changed files with 196 additions and 75 deletions
|
|
@ -550,29 +550,38 @@ class EnumDef(AbstractAttrDef):
|
|||
passed items or list of values for multiselection.
|
||||
multiselection (Optional[bool]): If True, multiselection is allowed.
|
||||
Output is list of selected items.
|
||||
placeholder (Optional[str]): Placeholder for UI purposes, only for
|
||||
multiselection enumeration.
|
||||
|
||||
"""
|
||||
type = "enum"
|
||||
|
||||
type_attributes = [
|
||||
"multiselection",
|
||||
"placeholder",
|
||||
]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
key: str,
|
||||
items: "EnumItemsInputType",
|
||||
default: "Union[str, List[Any]]" = None,
|
||||
multiselection: Optional[bool] = False,
|
||||
placeholder: Optional[str] = None,
|
||||
**kwargs
|
||||
):
|
||||
if not items:
|
||||
raise ValueError((
|
||||
"Empty 'items' value. {} must have"
|
||||
if multiselection is None:
|
||||
multiselection = False
|
||||
|
||||
if not items and not multiselection:
|
||||
raise ValueError(
|
||||
f"Empty 'items' value. {self.__class__.__name__} must have"
|
||||
" defined values on initialization."
|
||||
).format(self.__class__.__name__))
|
||||
)
|
||||
|
||||
items = self.prepare_enum_items(items)
|
||||
item_values = [item["value"] for item in items]
|
||||
item_values_set = set(item_values)
|
||||
if multiselection is None:
|
||||
multiselection = False
|
||||
|
||||
if multiselection:
|
||||
if default is None:
|
||||
|
|
@ -587,6 +596,7 @@ class EnumDef(AbstractAttrDef):
|
|||
self.items: List["EnumItemDict"] = items
|
||||
self._item_values: Set[Any] = item_values_set
|
||||
self.multiselection: bool = multiselection
|
||||
self.placeholder: Optional[str] = placeholder
|
||||
|
||||
def convert_value(self, value):
|
||||
if not self.multiselection:
|
||||
|
|
@ -612,7 +622,6 @@ class EnumDef(AbstractAttrDef):
|
|||
def serialize(self):
|
||||
data = super().serialize()
|
||||
data["items"] = copy.deepcopy(self.items)
|
||||
data["multiselection"] = self.multiselection
|
||||
return data
|
||||
|
||||
@staticmethod
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ from datetime import datetime
|
|||
from abc import ABC, abstractmethod
|
||||
from functools import lru_cache
|
||||
|
||||
import appdirs
|
||||
import platformdirs
|
||||
import ayon_api
|
||||
|
||||
_PLACEHOLDER = object()
|
||||
|
|
@ -17,7 +17,7 @@ _PLACEHOLDER = object()
|
|||
|
||||
def _get_ayon_appdirs(*args):
|
||||
return os.path.join(
|
||||
appdirs.user_data_dir("AYON", "Ynput"),
|
||||
platformdirs.user_data_dir("AYON", "Ynput"),
|
||||
*args
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue