Initial Commit
New modified String Function
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
import re
|
||||
|
||||
class StringFunction:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {
|
||||
"required": {
|
||||
"action": (["append", "replace"], {}),
|
||||
"tidy_tags": (["yes", "no"], {}),
|
||||
"text_a": ("STRING", {"multiline": True}),
|
||||
"text_b": ("STRING", {"multiline": True}),
|
||||
},
|
||||
"optional": {
|
||||
"text_c": ("STRING", {"multiline": True}),
|
||||
"text_d": ("STRING", {"multiline": True}),
|
||||
"text_e": ("STRING", {"multiline": True}),
|
||||
"text_f": ("STRING", {"multiline": True}),
|
||||
"text_g": ("STRING", {"multiline": True}),
|
||||
"text_h": ("STRING", {"multiline": True}),
|
||||
"text_i": ("STRING", {"multiline": True}),
|
||||
"text_j": ("STRING", {"multiline": True}),
|
||||
"text_k": ("STRING", {"multiline": True}),
|
||||
"text_l": ("STRING", {"multiline": True}),
|
||||
"text_m": ("STRING", {"multiline": True}),
|
||||
"text_n": ("STRING", {"multiline": True}),
|
||||
"text_o": ("STRING", {"multiline": True}),
|
||||
"text_p": ("STRING", {"multiline": True}),
|
||||
"text_q": ("STRING", {"multiline": True}),
|
||||
"text_r": ("STRING", {"multiline": True}),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("STRING",)
|
||||
FUNCTION = "exec"
|
||||
CATEGORY = "utils"
|
||||
OUTPUT_NODE = True
|
||||
|
||||
def exec(self, action, tidy_tags, text_a, text_b, text_c="", text_d="", text_e="", text_f="", text_g="", text_h="",
|
||||
text_i="", text_j="", text_k="", text_l="", text_m="", text_n="", text_o="", text_p="", text_q="", text_r=""):
|
||||
# Converted inputs are sent as the string of 'undefined' if not connected
|
||||
if text_a == "undefined":
|
||||
text_a = ""
|
||||
if text_b == "undefined":
|
||||
text_b = ""
|
||||
if text_c == "undefined":
|
||||
text_c = ""
|
||||
if text_d == "undefined":
|
||||
text_d = ""
|
||||
if text_e == "undefined":
|
||||
text_e = ""
|
||||
if text_f == "undefined":
|
||||
text_f = ""
|
||||
if text_g == "undefined":
|
||||
text_g = ""
|
||||
if text_h == "undefined":
|
||||
text_h = ""
|
||||
if text_i == "undefined":
|
||||
text_i = ""
|
||||
if text_j == "undefined":
|
||||
text_j = ""
|
||||
if text_k == "undefined":
|
||||
text_k = ""
|
||||
if text_l == "undefined":
|
||||
text_l = ""
|
||||
if text_m == "undefined":
|
||||
text_m = ""
|
||||
if text_n == "undefined":
|
||||
text_n = ""
|
||||
if text_o == "undefined":
|
||||
text_o = ""
|
||||
if text_p == "undefined":
|
||||
text_p = ""
|
||||
if text_q == "undefined":
|
||||
text_q = ""
|
||||
if text_r == "undefined":
|
||||
text_r = ""
|
||||
|
||||
tidy_tags = tidy_tags == "yes"
|
||||
out = ""
|
||||
if action == "append":
|
||||
out = (", " if tidy_tags else "").join(filter(None, [text_a, text_b, text_c, text_d, text_e, text_f, text_g, text_h, text_i, text_j, text_k, text_l, text_m, text_n, text_o, text_p, text_q, text_r]))
|
||||
else:
|
||||
if text_r is None:
|
||||
text_r = ""
|
||||
if text_b.startswith("/") and text_b.endswith("/"):
|
||||
regex = text_b[1:-1]
|
||||
out = re.sub(regex, text_r, text_a)
|
||||
else:
|
||||
out = text_a.replace(text_b, text_r)
|
||||
if tidy_tags:
|
||||
out = out.replace(" ", " ").replace(" ,", ",").replace(",,", ",").replace(",,", ",")
|
||||
return {"ui": {"text": (out,)}, "result": (out,)}
|
||||
|
||||
NODE_CLASS_MAPPINGS = {
|
||||
"StringFunction": StringFunction,
|
||||
}
|
||||
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
"StringFunction": "String Function Tree",
|
||||
}
|
||||
Reference in New Issue
Block a user