Files
alessandroperilli-OCS_Nodes/helpers.py
2025-07-06 12:06:07 +01:00

18 lines
520 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import torch
#Credit to pythongosssss for the AnyType class
class AnyType(str):
def __ne__(self, __value: object) -> bool:
return False
any = AnyType("*")
# User-friendly labels for node inputs
def _get_kw(label: str, kwargs: dict, args: tuple, pos: int):
"""Return the widget value whether Comfy passed it as kw‑ or positional arg."""
if label in kwargs:
return kwargs[label]
if len(args) > pos:
return args[pos]
raise TypeError(f"Missing required argument: {label}")