switch from any added

This commit is contained in:
Crystian
2025-06-02 02:03:31 +02:00
parent 4938ae65e3
commit 2c9833a3ef
4 changed files with 40 additions and 3 deletions
+3 -1
View File
@@ -13,7 +13,7 @@ logger.info(f'Crystools version: {version}')
from .nodes._names import CLASSES
from .nodes.primitive import CBoolean, CText, CTextML, CInteger, CFloat
from .nodes.switch import CSwitchBooleanAny, CSwitchBooleanLatent, CSwitchBooleanConditioning, CSwitchBooleanImage, \
CSwitchBooleanString, CSwitchBooleanMask
CSwitchBooleanString, CSwitchBooleanMask, CSwitchFromAny
from .nodes.debugger import CConsoleAny, CConsoleAnyToJson
from .nodes.image import CImagePreviewFromImage, CImageLoadWithMetadata, CImageGetResolution, CImagePreviewFromMetadata, \
CImageSaveWithExtraMetadata
@@ -38,6 +38,7 @@ NODE_CLASS_MAPPINGS = {
CLASSES.CLIST_ANY_NAME.value: CListAny,
CLASSES.CLIST_STRING_NAME.value: CListString,
CLASSES.CSWITCH_FROM_ANY_NAME.value: CSwitchFromAny,
CLASSES.CSWITCH_ANY_NAME.value: CSwitchBooleanAny,
CLASSES.CSWITCH_LATENT_NAME.value: CSwitchBooleanLatent,
CLASSES.CSWITCH_CONDITIONING_NAME.value: CSwitchBooleanConditioning,
@@ -75,6 +76,7 @@ NODE_DISPLAY_NAME_MAPPINGS = {
CLASSES.CLIST_ANY_NAME.value: CLASSES.CLIST_ANY_DESC.value,
CLASSES.CLIST_STRING_NAME.value: CLASSES.CLIST_STRING_DESC.value,
CLASSES.CSWITCH_FROM_ANY_NAME.value: CLASSES.CSWITCH_FROM_ANY_DESC.value,
CLASSES.CSWITCH_ANY_NAME.value: CLASSES.CSWITCH_ANY_DESC.value,
CLASSES.CSWITCH_LATENT_NAME.value: CLASSES.CSWITCH_LATENT_DESC.value,
CLASSES.CSWITCH_CONDITIONING_NAME.value: CLASSES.CSWITCH_CONDITIONING_DESC.value,
+2
View File
@@ -28,6 +28,8 @@ class CLASSES(Enum):
CLIST_STRING_NAME = 'List of strings [Crystools]'
CLIST_STRING_DESC = prefix + 'List of strings'
CSWITCH_FROM_ANY_NAME = 'Switch from any [Crystools]'
CSWITCH_FROM_ANY_DESC = prefix + 'Switch from any'
CSWITCH_ANY_NAME = 'Switch any [Crystools]'
CSWITCH_ANY_DESC = prefix + 'Switch any'
CSWITCH_STRING_NAME = 'Switch string [Crystools]'
+8 -2
View File
@@ -1,3 +1,4 @@
import fnmatch
import os
import random
import sys
@@ -234,12 +235,17 @@ class CImageLoadWithMetadata:
@classmethod
def INPUT_TYPES(cls):
input_dir = folder_paths.get_input_directory()
exclude_folders = ["clipspace"]
exclude_files = {"Thumbs.db", "*.DS_Store", "desktop.ini", "*.lock" }
exclude_folders = {"clipspace", ".*"}
file_list = []
for root, dirs, files in os.walk(input_dir):
# Exclude specific folders
dirs[:] = [d for d in dirs if d not in exclude_folders]
dirs[:] = [d for d in dirs if not any(fnmatch.fnmatch(d, exclude) for exclude in exclude_folders)]
files = [f for f in files if not any(fnmatch.fnmatch(f, exclude) for exclude in exclude_files)]
for file in files:
relpath = os.path.relpath(os.path.join(root, file), start=input_dir)
+27
View File
@@ -1,6 +1,33 @@
from ..core import BOOLEAN, STRING, CATEGORY, any, logger
class CSwitchFromAny:
def __init__(self):
pass
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"any": (any, ),
"boolean": BOOLEAN,
}
}
CATEGORY = CATEGORY.MAIN.value + CATEGORY.SWITCH.value
RETURN_TYPES = (any, any,)
RETURN_NAMES = ("on_true", "on_false",)
FUNCTION = "execute"
def execute(self, any,boolean=True):
logger.debug("Any switch: " + str(boolean))
if boolean:
return any, None
else:
return None, any
class CSwitchBooleanAny:
def __init__(self):
pass