Files
ComfyUI/custom_nodes/ComfyUI-Crystools/nodes/switch.py
jaidaken f09734b0ee
Some checks failed
Python Linting / Run Ruff (push) Has been cancelled
Python Linting / Run Pylint (push) Has been cancelled
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.10, [self-hosted Linux], stable) (push) Has been cancelled
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.11, [self-hosted Linux], stable) (push) Has been cancelled
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.12, [self-hosted Linux], stable) (push) Has been cancelled
Full Comfy CI Workflow Runs / test-unix-nightly (12.1, , linux, 3.11, [self-hosted Linux], nightly) (push) Has been cancelled
Execution Tests / test (macos-latest) (push) Has been cancelled
Execution Tests / test (ubuntu-latest) (push) Has been cancelled
Execution Tests / test (windows-latest) (push) Has been cancelled
Test server launches without errors / test (push) Has been cancelled
Unit Tests / test (macos-latest) (push) Has been cancelled
Unit Tests / test (ubuntu-latest) (push) Has been cancelled
Unit Tests / test (windows-2022) (push) Has been cancelled
Add custom nodes, Civitai loras (LFS), and vast.ai setup script
Includes 30 custom nodes committed directly, 7 Civitai-exclusive
loras stored via Git LFS, and a setup script that installs all
dependencies and downloads HuggingFace-hosted models on vast.ai.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 00:56:42 +00:00

226 lines
5.7 KiB
Python

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
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"on_true": (any, {"lazy": True}),
"on_false": (any, {"lazy": True}),
"boolean": BOOLEAN,
}
}
CATEGORY = CATEGORY.MAIN.value + CATEGORY.SWITCH.value
RETURN_TYPES = (any,)
FUNCTION = "execute"
def check_lazy_status(self, on_true=None, on_false=None, boolean=True):
needed = "on_true" if boolean else "on_false"
return [needed]
def execute(self, on_true, on_false, boolean=True):
logger.debug("Any switch: " + str(boolean))
if boolean:
return (on_true,)
else:
return (on_false,)
class CSwitchBooleanString:
def __init__(self):
pass
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"on_true": ("STRING", {"default": "", "lazy": True}),
"on_false": ("STRING", {"default": "", "lazy": True}),
"boolean": BOOLEAN,
}
}
CATEGORY = CATEGORY.MAIN.value + CATEGORY.SWITCH.value
RETURN_TYPES = ("STRING",)
RETURN_NAMES = ("string",)
FUNCTION = "execute"
def check_lazy_status(self, on_true=None, on_false=None, boolean=True):
needed = "on_true" if boolean else "on_false"
return [needed]
def execute(self, on_true, on_false, boolean=True):
logger.debug("String switch: " + str(boolean))
if boolean:
return (on_true,)
else:
return (on_false,)
class CSwitchBooleanConditioning:
def __init__(self):
pass
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"on_true": ("CONDITIONING", {"lazy": True}),
"on_false": ("CONDITIONING", {"lazy": True}),
"boolean": BOOLEAN,
}
}
CATEGORY = CATEGORY.MAIN.value + CATEGORY.SWITCH.value
RETURN_TYPES = ("CONDITIONING",)
RETURN_NAMES = ("conditioning",)
FUNCTION = "execute"
def check_lazy_status(self, on_true=None, on_false=None, boolean=True):
needed = "on_true" if boolean else "on_false"
return [needed]
def execute(self, on_true, on_false, boolean=True):
logger.debug("Conditioning switch: " + str(boolean))
if boolean:
return (on_true,)
else:
return (on_false,)
class CSwitchBooleanImage:
def __init__(self):
pass
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"on_true": ("IMAGE", {"lazy": True}),
"on_false": ("IMAGE", {"lazy": True}),
"boolean": BOOLEAN,
}
}
CATEGORY = CATEGORY.MAIN.value + CATEGORY.SWITCH.value
RETURN_TYPES = ("IMAGE",)
RETURN_NAMES = ("image",)
FUNCTION = "execute"
def check_lazy_status(self, on_true=None, on_false=None, boolean=True):
needed = "on_true" if boolean else "on_false"
return [needed]
def execute(self, on_true, on_false, boolean=True):
logger.debug("Image switch: " + str(boolean))
if boolean:
return (on_true,)
else:
return (on_false,)
class CSwitchBooleanLatent:
def __init__(self):
pass
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"on_true": ("LATENT", {"lazy": True}),
"on_false": ("LATENT", {"lazy": True}),
"boolean": BOOLEAN,
}
}
CATEGORY = CATEGORY.MAIN.value + CATEGORY.SWITCH.value
RETURN_TYPES = ("LATENT",)
RETURN_NAMES = ("latent",)
FUNCTION = "execute"
def check_lazy_status(self, on_true=None, on_false=None, boolean=True):
needed = "on_true" if boolean else "on_false"
return [needed]
def execute(self, on_true, on_false, boolean=True):
logger.debug("Latent switch: " + str(boolean))
if boolean:
return (on_true,)
else:
return (on_false,)
class CSwitchBooleanMask:
def __init__(self):
pass
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"on_true": ("MASK", {"lazy": True}),
"on_false": ("MASK", {"lazy": True}),
"boolean": BOOLEAN,
}
}
CATEGORY = CATEGORY.MAIN.value + CATEGORY.SWITCH.value
RETURN_TYPES = ("MASK",)
RETURN_NAMES = ("mask",)
FUNCTION = "execute"
def check_lazy_status(self, on_true=None, on_false=None, boolean=True):
needed = "on_true" if boolean else "on_false"
return [needed]
def execute(self, on_true, on_false, boolean=True):
logger.debug("Mask switch: " + str(boolean))
if boolean:
return (on_true,)
else:
return (on_false,)