From b2ff05e474e4cd3a6e26c15d6ab769050e6db358 Mon Sep 17 00:00:00 2001 From: Jehu Date: Thu, 25 Jan 2024 23:28:16 -0700 Subject: [PATCH] init --- .gitignore | 1 + README.md | 5 +++++ __init__.py | 3 +++ nodes.py | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 43 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 __init__.py create mode 100644 nodes.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ba0430d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +__pycache__/ \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..4e64bd8 --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +## ComfyUI Substring + +Just a simple substring node that takes *text* and *length* as input, and outputs the first *length* characters. + +To install, just git clone this repo in \ComfyUI\custom_nodes\ \ No newline at end of file diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..d721463 --- /dev/null +++ b/__init__.py @@ -0,0 +1,3 @@ +from .nodes import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS + +__all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS'] \ No newline at end of file diff --git a/nodes.py b/nodes.py new file mode 100644 index 0000000..9f72368 --- /dev/null +++ b/nodes.py @@ -0,0 +1,34 @@ +import os + +class SubstringFunction: + + def __init__(self): + pass + + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "text": ('STRING', {"multiline": True}), + "length": ('INT', {"default": 75, "min": 0}) + } + } + + RETURN_TYPES = ('STRING',) + FUNCTION = "exec" + CATEGORY = "utils" + OUTPUT_NODE = True + + def exec(self, text, length): + if text == "undefined": + text = "" + + out = text[:length] + return {"ui": {"text": (out,)}, "result": (out,)} + +NODE_CLASS_MAPPINGS = { + "SubstringTheory": SubstringFunction, +} +NODE_DISPLAY_NAME_MAPPINGS = { + "SubstringTheory": "Substring Node" +}