Added text replacer node
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import comfy.model_management
|
||||
|
||||
class TT_TextReplacer:
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"input_text_1": ("STRING", {"multiline": True}),
|
||||
"find_word": ("STRING", {"multiline": False}),
|
||||
"replace_word": ("STRING", {"multiline": False}),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("STRING",)
|
||||
RETURN_NAMES = ("output_text",)
|
||||
FUNCTION = "run"
|
||||
CATEGORY = "TT_TextTools"
|
||||
|
||||
def run(self, input_text_1, find_word, replace_word):
|
||||
# Replace the search word with the replace word in the first input text
|
||||
output_text = input_text_1.replace(find_word, replace_word)
|
||||
return (output_text,)
|
||||
|
||||
NODE_CLASS_MAPPINGS = {"TT_TextReplacer": TT_TextReplacer}
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {"TT_TextReplacer": "TT_TextReplacer"}
|
||||
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
from .TT_StoryCombiner import TT_StoryCombiner
|
||||
from .TT_TextInput import TT_TextInput
|
||||
from .TT_TextFileSelectorNode import TT_TextFileSelectorNode
|
||||
from .TT_TextReplacer import TT_TextReplacer
|
||||
|
||||
NODE_CLASS_MAPPINGS = {
|
||||
"TT_StoryCombiner": TT_StoryCombiner,
|
||||
"TT_TextInput": TT_TextInput,
|
||||
"TT_TextFileSelectorNode": TT_TextFileSelectorNode,
|
||||
"TT_TextReplacer": TT_TextReplacer,
|
||||
}
|
||||
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
"TT_StoryCombiner": "TT_StoryCombiner",
|
||||
"TT_TextInput": "TT_TextInput",
|
||||
"TT_TextFileSelectorNode": "TT_TextFileSelectorNode",
|
||||
"TT_TextReplacer": "TT_TextReplacer",
|
||||
}
|
||||
Reference in New Issue
Block a user