mirror of
https://git.datalinker.icu/kijai/ComfyUI-KJNodes.git
synced 2026-07-08 20:47:14 +08:00
Improve SomethingToString method in nodes.py
Refactor stringify method to handle input types more clearly.
This commit is contained in:
parent
c661baadd9
commit
d33068e263
@ -669,12 +669,13 @@ Converts any type to a string.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def stringify(self, input, prefix="", suffix=""):
|
def stringify(self, input, prefix="", suffix=""):
|
||||||
|
stringified = input
|
||||||
if isinstance(input, (int, float, bool)):
|
if isinstance(input, (int, float, bool)):
|
||||||
stringified = str(input)
|
stringified = str(input)
|
||||||
elif isinstance(input, list):
|
elif isinstance(input, list):
|
||||||
stringified = ', '.join(str(item) for item in input)
|
stringified = ', '.join(str(item) for item in input)
|
||||||
else:
|
# else:
|
||||||
return
|
# return
|
||||||
if prefix: # Check if prefix is not empty
|
if prefix: # Check if prefix is not empty
|
||||||
stringified = prefix + stringified # Add the prefix
|
stringified = prefix + stringified # Add the prefix
|
||||||
if suffix: # Check if suffix is not empty
|
if suffix: # Check if suffix is not empty
|
||||||
@ -2622,4 +2623,4 @@ class LazySwitchKJ:
|
|||||||
|
|
||||||
def switch(self, switch, on_false = None, on_true=None):
|
def switch(self, switch, on_false = None, on_true=None):
|
||||||
value = on_true if switch else on_false
|
value = on_true if switch else on_false
|
||||||
return (value,)
|
return (value,)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user