feat: Add UUID generation nodes

Introduces two new nodes for generating UUIDs:

- `UUIDGeneratorNode`: Generates a standard UUID4.
- `EnhancedUUIDGeneratorNode`: Provides options for generating UUIDs of types 1, 3, 4, and 5, with configurable namespaces, names, prefixes, and suffixes.

This commit also includes necessary updates to `pyproject.toml` and `__init__.py` files to integrate these nodes into the ComfyUI environment.
This commit is contained in:
cluny85
2025-05-17 14:12:19 +02:00
parent 25eb19e11f
commit a020cb402e
5 changed files with 58 additions and 20 deletions
+10
View File
@@ -0,0 +1,10 @@
"""Top-level package for ComfyUI-Scripting-Tools."""
from .src import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS
__all__ = [
"NODE_CLASS_MAPPINGS",
"NODE_DISPLAY_NAME_MAPPINGS"
]
__version__ = "1.0.0"
+2
View File
@@ -8,6 +8,8 @@ dependencies = ["# No external dependencies required"]
[project.urls]
Repository = "https://github.com/cluny85/ComfyUI-Scripting-Tools"
# Used by Comfy Registry https://comfyregistry.org
bugs = "https://github.com/cluny85/ComfyUI-Scripting-Tools/issues"
homepage = "https://github.com/cluny85/ComfyUI-Scripting-Tools"
[tool.comfy]
PublisherId = "cluny85"
+16 -2
View File
@@ -1,6 +1,20 @@
from .enhanced_uuid_generator import (
NODE_CLASS_MAPPINGS,
NODE_DISPLAY_NAME_MAPPINGS,
NODE_CLASS_MAPPINGS as enhanced_mappings,
NODE_DISPLAY_NAME_MAPPINGS as enhanced_display_mappings,
)
from .uuid_generator_node import (
NODE_CLASS_MAPPINGS as uuid_mappings,
NODE_DISPLAY_NAME_MAPPINGS as uuid_display_mappings,
)
# Merge the mappings
NODE_CLASS_MAPPINGS = {
**enhanced_mappings,
**uuid_mappings
}
NODE_DISPLAY_NAME_MAPPINGS = {
**enhanced_display_mappings,
**uuid_display_mappings
}
__all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS"]
+29 -17
View File
@@ -2,6 +2,25 @@ import uuid
class EnhancedUUIDGeneratorNode:
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"uuid_type": (["UUID1", "UUID3", "UUID4", "UUID5"], {"default": "UUID4"}),
"namespace_type": (["DNS", "URL", "OID", "X500", "CUSTOM"], {"default": "DNS"}),
"name_string": ("STRING", {"default": "example.com"}),
"trigger": ("INT", {"default": 0, "min": 0, "max": 1}),
},
"optional": {
"custom_namespace_uuid": ("STRING", {"default": ""}),
"prefix": ("STRING", {"default": ""}),
"suffix": ("STRING", {"default": ""})
}
}
RETURN_TYPES = ("STRING",)
FUNCTION = "generate_uuid_enhanced"
CATEGORY = "ComfyUI-Scripting-Tools"
def get_namespace(self, namespace_type, custom_namespace_uuid_str):
if namespace_type == "DNS":
@@ -16,13 +35,9 @@ class EnhancedUUIDGeneratorNode:
try:
return uuid.UUID(custom_namespace_uuid_str)
except ValueError:
raise ValueError(
"Invalid custom namespace UUID string."
)
raise ValueError("Invalid custom namespace UUID string.")
else:
raise ValueError(
"Invalid namespace type."
)
raise ValueError("Invalid namespace type.")
def generate_uuid_enhanced(
self,
@@ -34,25 +49,22 @@ class EnhancedUUIDGeneratorNode:
suffix="",
trigger=0,
):
if trigger == 0:
return None
namespace = self.get_namespace(namespace_type, custom_namespace_uuid)
# Siempre genera el UUID, ignora trigger
if uuid_type == "UUID1":
generated_uuid = uuid.uuid1()
elif uuid_type == "UUID3":
generated_uuid = uuid.uuid3(namespace, name_string)
elif uuid_type == "UUID4":
generated_uuid = uuid.uuid4()
elif uuid_type == "UUID3":
namespace = self.get_namespace(namespace_type, custom_namespace_uuid)
generated_uuid = uuid.uuid3(namespace, name_string)
elif uuid_type == "UUID5":
namespace = self.get_namespace(namespace_type, custom_namespace_uuid)
generated_uuid = uuid.uuid5(namespace, name_string)
else:
raise ValueError(
"Invalid UUID type."
)
raise ValueError("Invalid UUID type")
return f"{prefix}{generated_uuid}{suffix}"
result = f"{prefix}{str(generated_uuid)}{suffix}"
return (result,) # ComfyUI expects a tuple
# --- Mapeo para que ComfyUI reconozca el nodo ---
+1 -1
View File
@@ -45,7 +45,7 @@ class UUIDGeneratorNode:
# Define the category where the node will appear in ComfyUI's menu
CATEGORY = (
"utils/text"
"ComfyUI-Scripting-Tools"
) # You can change "utils/text" to your preference
# Indicates if this node is a final output node (like SaveImage)