mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-02 00:44:52 +01:00
added context manager method for using validation of dynamic template
This commit is contained in:
parent
41218b61ec
commit
027cb48a13
1 changed files with 18 additions and 0 deletions
|
|
@ -3,6 +3,7 @@ import re
|
|||
import json
|
||||
import copy
|
||||
import inspect
|
||||
import contextlib
|
||||
|
||||
from .exceptions import (
|
||||
SchemaTemplateMissingKeys,
|
||||
|
|
@ -167,6 +168,23 @@ class SchemasHub:
|
|||
return True
|
||||
return False
|
||||
|
||||
@contextlib.contextmanager
|
||||
def validating_dynamic(self, template_name):
|
||||
"""Template name is validating and validated.
|
||||
|
||||
Context manager that cares about storing template name validations of
|
||||
template.
|
||||
|
||||
This is to avoid infinite loop of dynamic children validation.
|
||||
"""
|
||||
self._validating_dynamic.add(template_name)
|
||||
try:
|
||||
yield
|
||||
self._validated_dynamic.add(template_name)
|
||||
|
||||
finally:
|
||||
self._validating_dynamic.remove(template_name)
|
||||
|
||||
def get_schema(self, schema_name):
|
||||
"""Get schema definition data by it's name.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue