"""The original Context Switch.""" from .constants import get_category, get_name from .context_utils import (ORIG_CTX_RETURN_TYPES, ORIG_CTX_RETURN_NAMES, is_context_empty, get_orig_context_return_tuple) class RgthreeContextSwitch: """The initial Context Switch node. For now, this will remain as-is but is otherwise backwards compatible with other Context nodes outputs. """ NAME = get_name("Context Switch") CATEGORY = get_category() @classmethod def INPUT_TYPES(cls): # pylint: disable = invalid-name, missing-function-docstring return { "required": {}, "optional": { "ctx_01": ("RGTHREE_CONTEXT",), "ctx_02": ("RGTHREE_CONTEXT",), "ctx_03": ("RGTHREE_CONTEXT",), "ctx_04": ("RGTHREE_CONTEXT",), "ctx_05": ("RGTHREE_CONTEXT",), }, } RETURN_TYPES = ORIG_CTX_RETURN_TYPES RETURN_NAMES = ORIG_CTX_RETURN_NAMES FUNCTION = "switch" def switch(self, ctx_01=None, ctx_02=None, ctx_03=None, ctx_04=None, ctx_05=None): """Chooses the first non-empty Context to output. As of right now, this returns the "original" context. We could expand it, or create another "Context Big Switch" and have all the outputs... """ ctx = None if not is_context_empty(ctx_01): ctx = ctx_01 elif not is_context_empty(ctx_02): ctx = ctx_02 elif not is_context_empty(ctx_03): ctx = ctx_03 elif not is_context_empty(ctx_04): ctx = ctx_04 elif not is_context_empty(ctx_05): ctx = ctx_05 return get_orig_context_return_tuple(ctx)