From 4d3616ac237c025c3a98720b50ec7fc51b5c03e8 Mon Sep 17 00:00:00 2001 From: phando Date: Tue, 3 Sep 2024 17:21:09 -0700 Subject: [PATCH] Adding concat but not working --- .DS_Store | Bin 6148 -> 6148 bytes nodes.py | 80 +++++++++++++++++++++++++++++++++++++++++++++++ startup_utils.py | 28 ----------------- 3 files changed, 80 insertions(+), 28 deletions(-) create mode 100755 nodes.py diff --git a/.DS_Store b/.DS_Store index 38734ca2de71d90578b12a191d5ff30a57f26d5c..348b6771151980b22b95efc19d594fd9c6a7e73d 100644 GIT binary patch delta 41 xcmZoMXfc@J&&V_}z tuple: + pattern = pattern.encode().decode("unicode_escape").lower() + text = text.lower() + + regex = rf'\b\w*{pattern}\w*\b' + matchList = re.findall(regex, text) + + match = matchList[0] if matchList else default + + # Prepare the output tuple + output = (match, matchList, len(matchList), len(matchList) > 0) + return output + + +class TextConcatenateDynamic: + def __init__(self): + pass + + @classmethod + def INPUT_TYPES(s): + min_input = 2 + max_input = 10 + inputs = { + "required": { + "delimiter": ("STRING", {"default": ",", "tooltip": "Delimiter to use for concatenation"}), + "count": ("INT", {"default": min_input, "min": min_input, "max": max_input}), + }, + } + + inputCount = inputs['required']['count'][1]['default'] + for i in range(1, inputCount+1): + inputs["dynamic"][f"text_{i+1}"] = ("STRING", {"default": "", "tooltip": f"Text input {i + 1}"}) + + return inputs + + # Define the return types + RETURN_TYPES = ("STRING",) + RETURN_NAMES = ("output",) + + FUNCTION = "textConcatenateDynamic" + CATEGORY = "Phando/Text" + + def textConcatenateDynamic(self, delimiter, count, optional_lora_stack=None, **kwargs): + inputs = [kwargs.get(f"text_{i + 1}", "") for i in range(count)] + concatenated_result = delimiter.join(inputs) + return (concatenated_result,) + + +NODE_CLASS_MAPPINGS = { + 'SearchBySubstring': SearchBySubstring, + 'TextConcatenateDynamic': TextConcatenateDynamic, +} + +NODE_DISPLAY_NAME_MAPPINGS = { + 'SearchBySubstring': 'Search by Substring', + 'TextConcatenateDynamic': 'Text Concatenate - Dynamic', +} \ No newline at end of file diff --git a/startup_utils.py b/startup_utils.py index b866eed..e69de29 100755 --- a/startup_utils.py +++ b/startup_utils.py @@ -1,28 +0,0 @@ -# import os -# from pathlib import Path - -# import folder_paths - -# def symlink_web_dir(local_path, extension_name): -# comfy_web_ext_root = Path(os.path.join(folder_paths.base_path, "web", "extensions")) -# target_dir = Path(os.path.join(comfy_web_ext_root, extension_name)) -# extension_path = Path(__file__).parent.resolve() - -# if target_dir.exists(): -# print(f"Web extensions folder found at {target_dir}") -# elif comfy_web_ext_root.exists(): -# try: -# os.symlink((os.path.join(extension_path, local_path)), target_dir) -# except OSError as e: # OSError -# print( -# f"Error:\n{e}\n" -# f"Failed to create symlink to {target_dir}. Please copy the folder manually.\n" -# f"Source: {os.path.join(extension_path, local_path)}\n" -# f"Target: {target_dir}" -# ) -# except Exception as e: -# print(f"Unexpected error:\n{e}") -# else: -# print( -# f"Failed to find comfy root automatically, please copy the folder {os.path.join(extension_path, 'web')} manually in the web/extensions folder of ComfyUI" -# )