remove randline since PR exists

This commit is contained in:
yoinked 2025-06-20 05:08:55 +00:00
parent e877471dfd
commit 5162e90948

View File

@ -1,6 +1,5 @@
import re import re
import os import os
import torch
import folder_paths import folder_paths
from comfy.comfy_types.node_typing import IO from comfy.comfy_types.node_typing import IO
@ -367,35 +366,6 @@ class LoadText():
return True return True
class GetRandomLine():
DESCRIPTION = "Obtain a random line from a multiline string."
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"text": (IO.STRING, {"multiline": True, "default": ""}),
"seed": (IO.INT, {"default": 0,
"min": 0,
"max": 2147483647,
"step": 1,
"control_after_generate": True,
"display": "number"},)
}
}
RETURN_TYPES = (IO.STRING,)
FUNCTION = "execute"
CATEGORY = "utils/string"
def execute(self, text, seed=0):
generator = torch.Generator()
generator.manual_seed(seed)
lines = text.splitlines()
max_lines = len(lines)
idx = torch.randint(0, max_lines, (1,), generator=generator).item()
return (lines[idx],)
NODE_CLASS_MAPPINGS = { NODE_CLASS_MAPPINGS = {
"StringConcatenate": StringConcatenate, "StringConcatenate": StringConcatenate,
"StringSubstring": StringSubstring, "StringSubstring": StringSubstring,
@ -408,8 +378,7 @@ NODE_CLASS_MAPPINGS = {
"RegexMatch": RegexMatch, "RegexMatch": RegexMatch,
"RegexExtract": RegexExtract, "RegexExtract": RegexExtract,
"RegexReplace": RegexReplace, "RegexReplace": RegexReplace,
"LoadText": LoadText, "LoadText": LoadText
"GetRandomLine": GetRandomLine
} }
NODE_DISPLAY_NAME_MAPPINGS = { NODE_DISPLAY_NAME_MAPPINGS = {
@ -424,6 +393,5 @@ NODE_DISPLAY_NAME_MAPPINGS = {
"RegexMatch": "Regex Match", "RegexMatch": "Regex Match",
"RegexExtract": "Regex Extract", "RegexExtract": "Regex Extract",
"RegexReplace": "Regex Replace", "RegexReplace": "Regex Replace",
"LoadText": "Load Text", "LoadText": "Load Text"
"GetRandomLine": "Get Random Line"
} }