Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
55d735087f |
+4
-1
@@ -22,6 +22,7 @@ from custom_nodes.Comfy_KepListStuff.nodes.range_nodes import (
|
||||
IntNumStepsRangeNode,
|
||||
FloatNumStepsRangeNode,
|
||||
)
|
||||
from custom_nodes.Comfy_KepListStuff.nodes.strings import StringReplace
|
||||
from custom_nodes.Comfy_KepListStuff.nodes.xy import UnzippedProductAny
|
||||
|
||||
NODE_CLASS_MAPPINGS = {
|
||||
@@ -43,7 +44,8 @@ NODE_CLASS_MAPPINGS = {
|
||||
"Kep_VariableImageBuilder": VariableImageBuilder,
|
||||
"Kep_ReverseList": ReverseList,
|
||||
"Kep_RepeatList": RepeatList,
|
||||
"Kep_JoinListAny": JoinListAny
|
||||
"Kep_JoinListAny": JoinListAny,
|
||||
"Kep_ReplaceList": StringReplace,
|
||||
}
|
||||
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
@@ -55,4 +57,5 @@ NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
"Kep_RepeatList": "Repeat List",
|
||||
"Kep_JoinListAny": "Join List Any",
|
||||
"KepStringListFromNewline": "String List From Newline",
|
||||
"Kep_ReplaceList": "Replace With List",
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
from typing import Any, Dict, List, Tuple
|
||||
|
||||
from custom_nodes.Comfy_KepListStuff.utils import AnyType
|
||||
|
||||
any_type = AnyType("*")
|
||||
|
||||
|
||||
class StringReplace:
|
||||
def __init__(self) -> None:
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(self) -> Dict[str, Dict[str, Any]]:
|
||||
return {
|
||||
"required": {
|
||||
"String": ("STRING", {"multiline": True}),
|
||||
"Old": ("STRING", {"multiline": False}),
|
||||
"New": (any_type, {}),
|
||||
},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("STRING",)
|
||||
RETURN_NAMES = ("Strings",)
|
||||
INPUT_IS_LIST = True
|
||||
OUTPUT_IS_LIST = (True,)
|
||||
FUNCTION = "list_replace"
|
||||
|
||||
CATEGORY = "List Stuff"
|
||||
|
||||
def list_replace(self, String: List[str], Old: List[str], New: List[Any]) -> Tuple[List[str]]:
|
||||
if len(Old) != 1:
|
||||
raise ValueError("Old does not support multiple values")
|
||||
if len(String) != 1:
|
||||
raise ValueError("String does not support multiple values")
|
||||
|
||||
returns = []
|
||||
for replacement in New:
|
||||
returns.append(String[0].replace(Old[0], str(replacement)))
|
||||
return (returns,)
|
||||
Reference in New Issue
Block a user