Add DarkAnyToString because mtb Any to String is broken

This commit is contained in:
Aaron C. de Bruyn
2024-09-10 12:59:22 -07:00
parent 40e7730938
commit a8a1e11284
2 changed files with 49 additions and 0 deletions
+3
View File
@@ -8,6 +8,7 @@ from .modules import faces
from .modules import prompts
from .modules import files
from .modules import checkpoints
from .modules import convert
logger = logging.getLogger(__name__)
@@ -21,6 +22,7 @@ NODE_CLASS_MAPPINGS = {
"DarkFaceIndexGenerator": faces.DarkFaceIndexGenerator,
"DarkCheckpointRandomizer": checkpoints.DarkCheckpointRandomizer,
"DarkCheckpointSwitcher": checkpoints.DarkCheckpointSwitcher,
"DarkAnyToString": convert.DarkAnyToString,
}
NODE_DISPLAY_NAME_MAPPINGS = {
@@ -32,6 +34,7 @@ NODE_DISPLAY_NAME_MAPPINGS = {
"DarkFaceIndexGenerator": "Dark Face Index Generator",
"DarkCheckpointRandomizer": "Dark Checkpoint Randomizer",
"DarkCheckpointSwitcher": "Dark Checkpoint Switcher",
"DarkAnyToString": "Dark Any to String",
}
__all__ = [NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS]
+46
View File
@@ -0,0 +1,46 @@
__version__ = "0.0.7"
import logging
from .utils.darkdata import DarkFolderBase
logger = logging.getLogger(__name__)
# AnyType trick taken from here: https://github.com/comfyanonymous/ComfyUI/discussions/4830
class AnyType(str):
def __ne__(self, __value: object) -> bool:
return False
any_typ = AnyType("*")
class DarkAnyToString(object):
"""
Convert anything to a string
"""
def __init__(self):
pass
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"anything": (
any_typ,
{
"forceInput": True,
},
),
},
}
RETURN_TYPES = ("STRING",)
FUNCTION = "any_to_string"
CATEGORY = "DarkPrompt"
def any_to_string(self, anything):
return (str(anything),)