Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dec733bd0a |
+5
-2
@@ -11,20 +11,23 @@ from .nodes_extract import *
|
||||
class DictToolsExtension(_ComfyExtension):
|
||||
async def get_node_list(self) -> list[type[_io.ComfyNode]]:
|
||||
return [
|
||||
DictAddAny,
|
||||
# Add:
|
||||
DictAddAny, DictAddAnyKey,
|
||||
DictAddBool, DictAddFloat, DictAddInt, DictAddString,
|
||||
DictAddCond, DictAddImage, DictAddLatent, DictAddMask,
|
||||
DictAddGuider, DictAddNoise, DictAddSampler, DictAddSigmas,
|
||||
DictAddClip, DictAddClipVision, DictAddControlNet, DictAddGligen, DictAddLora, DictAddModel, DictAddUpscale, DictAddVae,
|
||||
DictAddAnyOld1, DictAddStringOld1,
|
||||
|
||||
DictExtractAny,
|
||||
# Extract:
|
||||
DictExtractAny, DictExtractAnyKey,
|
||||
DictExtractBool, DictExtractFloat, DictExtractInt, DictExtractString,
|
||||
DictExtractCond, DictExtractImage, DictExtractLatent, DictExtractMask,
|
||||
DictExtractGuider, DictExtractNoise, DictExtractSampler, DictExtractSigmas,
|
||||
DictExtractClip, DictExtractClipVision, DictExtractControlNet, DictExtractGligen, DictExtractLora, DictExtractModel, DictExtractUpscale, DictExtractVae,
|
||||
DictExtractStringOld1,
|
||||
|
||||
# Root category:
|
||||
TextToDict, TextToDictOld1, TextToDictOld2,
|
||||
]
|
||||
|
||||
|
||||
@@ -310,6 +310,44 @@ class DictAddAny(_BaseNode):
|
||||
# ----------------------------------------------------------
|
||||
|
||||
|
||||
class DictAddAnyKey(_BaseNode):
|
||||
"""Add/update any-type item with any-type key to a Dict."""
|
||||
_schema = _io.Schema(
|
||||
node_id=f'DictAddAnyKey{_pack_id}',
|
||||
display_name='◯ANY-Key◯ → Dict🗂️',
|
||||
category=_category_add,
|
||||
description=_format_docstring(_cleandoc(__doc__)),
|
||||
inputs=[
|
||||
_DICT_INPUT_OPTIONAL,
|
||||
_io.AnyType.Input(
|
||||
'key',
|
||||
optional=True,
|
||||
tooltip="Key (of ANY type) for the item inserted into the dict.",
|
||||
),
|
||||
_io.AnyType.Input(
|
||||
'value',
|
||||
optional=True,
|
||||
tooltip="The actual any-type item to add into the Dict."
|
||||
),
|
||||
],
|
||||
outputs=[_DICT_OUTPUT],
|
||||
)
|
||||
|
||||
# noinspection PyShadowingBuiltins
|
||||
@classmethod
|
||||
def execute(cls,
|
||||
key: _A = None, value: _A = None,
|
||||
dict: _O[_DictMap] = None,
|
||||
) -> _io.NodeOutput:
|
||||
"""Add/update any-type item with any-type key to a Dict."""
|
||||
# No type check: neither for the key, nor for value
|
||||
result = _new_updated_dict(dict, {key: value})
|
||||
return _io.NodeOutput(result)
|
||||
|
||||
|
||||
# ----------------------------------------------------------
|
||||
|
||||
|
||||
class DictAddString(_BaseNode):
|
||||
"""Add/update a string item to a Dict."""
|
||||
_schema = _io.Schema(
|
||||
|
||||
@@ -291,6 +291,49 @@ class DictExtractAny(_BaseNode):
|
||||
return _io.NodeOutput(value)
|
||||
|
||||
|
||||
# ----------------------------------------------------------
|
||||
|
||||
|
||||
class DictExtractAnyKey(_BaseNode):
|
||||
"""Extract any-type item with any-type key from a Dict."""
|
||||
_schema = _io.Schema(
|
||||
node_id=f'DictExtractAnyKey{_pack_id}',
|
||||
display_name='🗂️Dict → ◯ANY-Key◯',
|
||||
category=_category_extract,
|
||||
description=_format_docstring(_cleandoc(__doc__)),
|
||||
inputs=[
|
||||
_DICT_INPUT_REQUIRED,
|
||||
_io.AnyType.Input(
|
||||
'key',
|
||||
optional=True,
|
||||
tooltip="Key (of ANY type) for the item extracted from the dict.",
|
||||
),
|
||||
],
|
||||
outputs=[
|
||||
_io.AnyType.Output(
|
||||
'value',
|
||||
tooltip="The actual any-type item extracted from the Dict."
|
||||
),
|
||||
],
|
||||
# hidden=[_io.Hidden.unique_id],
|
||||
)
|
||||
|
||||
# noinspection PyShadowingBuiltins
|
||||
@classmethod
|
||||
def execute(cls,
|
||||
dict: _DictMap, key: _A = None,
|
||||
) -> _io.NodeOutput:
|
||||
"""Extract any-type item with any-type key from a Dict."""
|
||||
dict = _validate_required_dict(dict)
|
||||
# No key-check
|
||||
value = _get_key(dict, key)
|
||||
# No output-type check
|
||||
return _io.NodeOutput(value)
|
||||
|
||||
|
||||
# ----------------------------------------------------------
|
||||
|
||||
|
||||
class DictExtractString(_BaseNode):
|
||||
"""Extract a string item from a Dict."""
|
||||
_schema = _io.Schema(
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "dict_tools"
|
||||
version = "3.2.0"
|
||||
version = "3.2.1"
|
||||
description = "Essential nodes to use dictionaries in ComfyUI: for smart prompt-formatting, general organization (passing a single connection instead of spaghetti), or anything else."
|
||||
license = {file = "LICENSE.md"}
|
||||
readme = "README.md"
|
||||
|
||||
Reference in New Issue
Block a user