add SelectAnyValues node
This commit is contained in:
+13
@@ -0,0 +1,13 @@
|
||||
|
||||
from .nodes import SelectAnyValues
|
||||
|
||||
NODE_CLASS_MAPPINGS = {
|
||||
"SelectAnyValues": SelectAnyValues,
|
||||
}
|
||||
|
||||
# A dictionary that contains the friendly/humanly readable titles for the nodes
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
"SelectAnyValues": "Select Any Values Node",
|
||||
}
|
||||
|
||||
# WEB_DIRECTORY = "./web"
|
||||
@@ -0,0 +1,81 @@
|
||||
# https://stackoverflow.com/questions/4842424/list-of-ansi-color-escape-sequences
|
||||
# https://en.wikipedia.org/wiki/ANSI_escape_code#3-bit_and_4-bit
|
||||
COLORS = {
|
||||
'BLACK': '\33[30m',
|
||||
'RED': '\33[31m',
|
||||
'GREEN': '\33[32m',
|
||||
'YELLOW': '\33[33m',
|
||||
'BLUE': '\33[34m',
|
||||
'MAGENTA': '\33[35m',
|
||||
'CYAN': '\33[36m',
|
||||
'WHITE': '\33[37m',
|
||||
'GREY': '\33[90m',
|
||||
'BRIGHT_RED': '\33[91m',
|
||||
'BRIGHT_GREEN': '\33[92m',
|
||||
'BRIGHT_YELLOW': '\33[93m',
|
||||
'BRIGHT_BLUE': '\33[94m',
|
||||
'BRIGHT_MAGENTA': '\33[95m',
|
||||
'BRIGHT_CYAN': '\33[96m',
|
||||
'BRIGHT_WHITE': '\33[97m',
|
||||
# Styles.
|
||||
'RESET': '\33[0m',
|
||||
'BOLD': '\33[1m',
|
||||
'NORMAL': '\33[22m',
|
||||
'ITALIC': '\33[3m',
|
||||
'UNDERLINE': '\33[4m',
|
||||
'BLINK': '\33[5m',
|
||||
'BLINK2': '\33[6m',
|
||||
'SELECTED': '\33[7m',
|
||||
# Backgrounds
|
||||
'BG_BLACK': '\33[40m',
|
||||
'BG_RED': '\33[41m',
|
||||
'BG_GREEN': '\33[42m',
|
||||
'BG_YELLOW': '\33[43m',
|
||||
'BG_BLUE': '\33[44m',
|
||||
'BG_MAGENTA': '\33[45m',
|
||||
'BG_CYAN': '\33[46m',
|
||||
'BG_WHITE': '\33[47m',
|
||||
'BG_GREY': '\33[100m',
|
||||
'BG_BRIGHT_RED': '\33[101m',
|
||||
'BG_BRIGHT_GREEN': '\33[102m',
|
||||
'BG_BRIGHT_YELLOW': '\33[103m',
|
||||
'BG_BRIGHT_BLUE': '\33[104m',
|
||||
'BG_BRIGHT_MAGENTA': '\33[105m',
|
||||
'BG_BRIGHT_CYAN': '\33[106m',
|
||||
'BG_BRIGHT_WHITE': '\33[107m',
|
||||
}
|
||||
|
||||
|
||||
def log_node_success(node_name, message, msg_color='RESET'):
|
||||
"""Logs a success message."""
|
||||
_log_node("BRIGHT_GREEN", node_name, message, msg_color=msg_color)
|
||||
|
||||
|
||||
def log_node_info(node_name, message, msg_color='RESET'):
|
||||
"""Logs an info message."""
|
||||
_log_node("CYAN", node_name, message, msg_color=msg_color)
|
||||
|
||||
|
||||
def log_node_warn(node_name, message, msg_color='RESET'):
|
||||
"""Logs an warn message."""
|
||||
_log_node("YELLOW", node_name, message, msg_color=msg_color)
|
||||
|
||||
|
||||
def log_node(node_name, message, msg_color='RESET'):
|
||||
"""Logs a message."""
|
||||
_log_node("CYAN", node_name, message, msg_color=msg_color)
|
||||
|
||||
|
||||
def _log_node(color, node_name, message, msg_color='RESET'):
|
||||
"""Logs for a node message."""
|
||||
log(message, color=color, prefix=node_name.replace(" (rgthree)", ""), msg_color=msg_color)
|
||||
|
||||
|
||||
def log(message, color=None, msg_color=None, prefix=None):
|
||||
"""Basic logging."""
|
||||
color = COLORS[color] if color is not None and color in COLORS else COLORS["BRIGHT_GREEN"]
|
||||
msg_color = COLORS[msg_color] if msg_color is not None and msg_color in COLORS else ''
|
||||
prefix = f'[{prefix}]' if prefix is not None else ''
|
||||
msg = f'{color}{prefix}'
|
||||
msg += f'{msg_color} {message}{COLORS["RESET"]}'
|
||||
print(msg)
|
||||
@@ -0,0 +1,55 @@
|
||||
from .log import log_node_warn, log_node_info
|
||||
|
||||
class AnyType(str):
|
||||
"""A special class that is always equal in not equal comparisons. Credit to pythongosssss"""
|
||||
|
||||
def __eq__(self, _) -> bool:
|
||||
return True
|
||||
|
||||
def __ne__(self, __value: object) -> bool:
|
||||
return False
|
||||
|
||||
any = AnyType("*")
|
||||
|
||||
class SelectAnyValues:
|
||||
|
||||
NAME = 'Select Any Values'
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"enable": ("BOOLEAN", {"default": True}),
|
||||
"strategy": (["FirstEnable", "LastEnable"],),
|
||||
},
|
||||
"optional": {
|
||||
"input1": (any, {"forceInput": True}),
|
||||
"input2": (any, {"forceInput": True}),
|
||||
"input3": (any, {"forceInput": True}),
|
||||
"input4": (any, {"forceInput": True}),
|
||||
"input5": (any, {"forceInput": True}),
|
||||
"input6": (any, {"forceInput": True}),
|
||||
"input7": (any, {"forceInput": True}),
|
||||
"input8": (any, {"forceInput": True}),
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
CATEGORY = "SelectAny"
|
||||
RETURN_TYPES = (any,)
|
||||
RETURN_NAMES = ("output",)
|
||||
|
||||
FUNCTION = "execute"
|
||||
|
||||
def execute(self, enable=True,strategy=None,input1=None,input2=None, input3=None,input4=None,input5=None,input6=None, input7=None, input8=None):
|
||||
valueList = [input1, input2,input3,input4,input5,input6,input7,input8]
|
||||
if strategy == "LastEnable":
|
||||
valueList.reverse()
|
||||
for item in valueList:
|
||||
if item != None:
|
||||
return (item,)
|
||||
|
||||
return (None,)
|
||||
Reference in New Issue
Block a user