Files
xelavi9966-cell-ComfyUI-Tag…/tag_table_node.py
T
2026-03-11 15:46:34 +03:00

50 lines
1.2 KiB
Python

import json
class TagTableNode:
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"rows": ("INT", {
"default": 5,
"min": 1,
"max": 100,
"step": 1
}),
"table_data": ("STRING", {
"default": "[]",
"multiline": True
}),
}
}
RETURN_TYPES = ("STRING",)
RETURN_NAMES = ("tags_text",)
FUNCTION = "build_text"
CATEGORY = "LeraTools"
def build_text(self, rows, table_data):
try:
data = json.loads(table_data)
if not isinstance(data, list):
data = []
except Exception:
data = []
parts = []
for row in data:
if not isinstance(row, dict):
continue
enabled = bool(row.get("enabled", True))
if not enabled:
continue
tag = str(row.get("tag", "")).strip()
if tag:
parts.append(tag)
result = " ".join(parts)
return (result,)