-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathnode_validate.py
More file actions
58 lines (50 loc) · 1.67 KB
/
node_validate.py
File metadata and controls
58 lines (50 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# encoding: utf-8
"""Code for the dict-validator node."""
from inspect import cleandoc as _cleandoc
from comfy_api.latest import io as _io
from .__meta import (
category as _category,
pack_id_suffix as _pack_id
)
from .__typing import _A, _U, _O, _t, T as _T, DictMap as _DictMap
from ._io_custom import (
_BaseNode,
_DICT_INPUT_OPTIONAL, _DICT_OUTPUT,
_schema_old_name
)
from ._validate_funcs import _verify_format_dict
from .docstring_formatter import format_docstring as _format_docstring
# ----------------------------------------------------------
class ValidateKeys(_BaseNode):
"""
Verify the dict to have string-formatting-compatible keys. No need to add it before "String Formatter" node,
but it might be handy to verify the dict in the very beginning of the graph - right after the keys are set.
"""
_schema = _io.Schema(
node_id=f'ValidateKeys{_pack_id}',
display_name='Validate Dict',
category=_category,
description=_format_docstring(_cleandoc(__doc__)),
inputs=[_DICT_INPUT_OPTIONAL],
outputs=[_DICT_OUTPUT],
# hidden=[_io.Hidden.unique_id],
is_output_node=True,
)
@classmethod
def execute(cls, dict: _O[_DictMap] = None) -> _io.NodeOutput:
# try:
# _verify_input_dict(dict, error_if_none=True)
# except Exception:
# _show_text_on_node('❌', unique_id)
# raise
# return (Null, )
# _show_text_on_node('✅', unique_id)
_verify_format_dict(dict, error_if_none=True)
return _io.NodeOutput(dict)
# ==========================================================
# Deprecated node with old ID (for backwards compatibility)
class ValidateKeysOld1(ValidateKeys):
_schema = _schema_old_name(
ValidateKeys._schema,
'StringConstructorValidateKeys'
)