Add replace string, make globally unique.
This commit is contained in:
+11
-8
@@ -1,20 +1,23 @@
|
||||
from .save_string import SaveString
|
||||
from .print_string import PrintString
|
||||
from .replace_string import ReplaceString
|
||||
from .tokenizer_vocab import TokenizerVocab
|
||||
from .pick_item_json import PickItemJson
|
||||
|
||||
NODE_CLASS_MAPPINGS = {
|
||||
"SaveString": SaveString,
|
||||
"TokenizerVocab": TokenizerVocab,
|
||||
"PickItemJson": PickItemJson,
|
||||
"PrintString": PrintString,
|
||||
"IW_SaveString": SaveString,
|
||||
"IW_PrintString": PrintString,
|
||||
"IW_ReplaceString": ReplaceString,
|
||||
"IW_TokenizerVocab": TokenizerVocab,
|
||||
"IW_PickItemJson": PickItemJson,
|
||||
}
|
||||
|
||||
# A dictionary that contains the friendly/humanly readable titles for the nodes
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
"SaveString": "IW SaveString",
|
||||
"TokenizerVocab": "IW TokenizerVocab",
|
||||
"PickItemJson": "IW PickItemJson",
|
||||
"PrintString": "IW PrintString",
|
||||
"IW_SaveString": "IW SaveString",
|
||||
"IW_TokenizerVocab": "IW TokenizerVocab",
|
||||
"IW_PickItemJson": "IW PickItemJson",
|
||||
"IW_PrintString": "IW PrintString",
|
||||
"IW_ReplaceString": "IW ReplaceString",
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ class PickItemJson:
|
||||
return {
|
||||
"required": {
|
||||
"pick_value": ("INT",{"defaultInput": True, "default": 0}),
|
||||
"input": ("STRING",{"defaultInput": True, "default": "", "dynamicPrompts": False}),
|
||||
"input": ("STRING",{"defaultInput": True, "default": "", "dynamicPrompts": False, "multiline": True}),
|
||||
},
|
||||
"optional": {
|
||||
},
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import os
|
||||
import json
|
||||
|
||||
class ReplaceString:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {
|
||||
"required": {
|
||||
"haystack": ("STRING",{"defaultInput": True, "default": "{}", "multiline": True}),
|
||||
"needle": ("STRING",{"defaultInput": False, "default": "%REPLACE%", "dynamicPrompts": False}),
|
||||
"value": ("STRING",{"defaultInput": True, "default": "", "dynamicPrompts": False}),
|
||||
"input_type": (["json", "verbatim"], {"default": "verbatim"}),
|
||||
},
|
||||
"optional": {
|
||||
},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("STRING", )
|
||||
FUNCTION = "execute"
|
||||
|
||||
CATEGORY = "iw"
|
||||
|
||||
def execute(self, haystack, needle, value, input_type):
|
||||
if input_type == "json":
|
||||
z = json.loads(value)
|
||||
if type(z) is str:
|
||||
value = z
|
||||
if type(z) is list:
|
||||
value = " ".join(z)
|
||||
return (haystack.replace(needle, value),)
|
||||
Reference in New Issue
Block a user