mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-02 08:54:53 +01:00
added schema_validations method
This commit is contained in:
parent
6e17a6012a
commit
9e0f32fce8
2 changed files with 18 additions and 6 deletions
|
|
@ -130,6 +130,11 @@ class BaseEntity:
|
|||
def get_child_path(self, child_obj):
|
||||
pass
|
||||
|
||||
|
||||
@abstractmethod
|
||||
def schema_validations(self):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def set_override_state(self, state):
|
||||
pass
|
||||
|
|
@ -356,6 +361,7 @@ class RootEntity(BaseEntity):
|
|||
update_default_value = None
|
||||
update_studio_values = None
|
||||
update_project_values = None
|
||||
schema_validations = None
|
||||
|
||||
def __init__(self, schema_data):
|
||||
super(RootEntity, self).__init__(schema_data, None, None)
|
||||
|
|
@ -429,6 +435,8 @@ class RootEntity(BaseEntity):
|
|||
self.non_gui_children = {}
|
||||
self.gui_wrappers = []
|
||||
self._add_children(self.schema_data)
|
||||
for children in self.children:
|
||||
children.schema_validations()
|
||||
|
||||
def create_schema_object(self, schema_data, *args, **kwargs):
|
||||
if self._loaded_types is None:
|
||||
|
|
@ -660,6 +668,7 @@ class SystemRootEntity(RootEntity):
|
|||
def reset(self, new_state=None):
|
||||
if new_state is None:
|
||||
new_state = self.override_state
|
||||
|
||||
if new_state is OverrideState.NOT_DEFINED:
|
||||
new_state = OverrideState.DEFAULTS
|
||||
|
||||
|
|
|
|||
|
|
@ -140,28 +140,31 @@ class ItemEntity(BaseEntity):
|
|||
|
||||
self.item_initalization()
|
||||
|
||||
def schema_validations(self):
|
||||
if self.valid_value_types is NOT_SET:
|
||||
raise ValueError("Attribute `valid_value_types` is not filled.")
|
||||
|
||||
if self.require_key and not self.key:
|
||||
error_msg = "Missing \"key\" in schema data. {}".format(
|
||||
str(schema_data).replace("'", '"')
|
||||
error_msg = "{}: Missing \"key\" in schema data. {}".format(
|
||||
self.path, str(self.schema_data).replace("'", '"')
|
||||
)
|
||||
raise KeyError(error_msg)
|
||||
|
||||
if not self.label and self.is_group:
|
||||
raise ValueError(
|
||||
"Item is set as `is_group` but has empty `label`."
|
||||
"{}: Item is set as `is_group` but has empty `label`.".format(
|
||||
self.path
|
||||
)
|
||||
)
|
||||
|
||||
if self.is_group and self.group_item:
|
||||
raise ValueError("Group item in group item")
|
||||
raise ValueError("{}: Group item in group item".format(self.path))
|
||||
|
||||
if not self.file_item and self.is_env_group:
|
||||
raise ValueError((
|
||||
"Environment item is not inside file"
|
||||
"{}: Environment item is not inside file"
|
||||
" item so can't store metadata for defaults."
|
||||
))
|
||||
).format(self.path))
|
||||
|
||||
@abstractmethod
|
||||
def item_initalization(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue