version 0.2.1

Sort the node names
This commit is contained in:
StableLlama
2025-05-15 21:13:06 +02:00
parent 5cdd214a78
commit e5eec7c74d
15 changed files with 2704 additions and 2728 deletions
+77 -77
View File
@@ -2,6 +2,77 @@ from inspect import cleandoc
import re
from comfy.comfy_types.node_typing import IO, ComfyNodeABC
class RegexFindallDataList(ComfyNodeABC):
"""
Returns all non-overlapping matches of a pattern in the string as a list of strings.
"""
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"string": (IO.STRING, {}),
"pattern": (IO.STRING, {}),
}
}
RETURN_TYPES = (IO.STRING,)
CATEGORY = "Basic/STRING/regex"
DESCRIPTION = cleandoc(__doc__ or "")
FUNCTION = "findall"
OUTPUT_IS_LIST = (True,)
def findall(self, pattern: str, string: str) -> tuple[list[str]]:
return (re.findall(pattern, string),)
class RegexFindallList(ComfyNodeABC):
"""
Returns all non-overlapping matches of a pattern in the string as a list of strings.
"""
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"string": (IO.STRING, {}),
"pattern": (IO.STRING, {}),
}
}
RETURN_TYPES = ("LIST",)
CATEGORY = "Basic/STRING/regex"
DESCRIPTION = cleandoc(__doc__ or "")
FUNCTION = "findall"
def findall(self, pattern: str, string: str) -> tuple[list[str]]:
return (re.findall(pattern, string),)
class RegexGroupDict(ComfyNodeABC):
"""
Searches the string with the given pattern and returns a DICT of named groups.
If no match is found, it returns an empty DICT.
"""
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"string": (IO.STRING, {}),
"pattern": (IO.STRING, {}),
}
}
RETURN_TYPES = ("DICT",)
CATEGORY = "Basic/STRING/regex"
DESCRIPTION = cleandoc(__doc__ or "")
FUNCTION = "groupdict"
def groupdict(self, pattern: str, string: str) -> tuple[dict]:
match = re.search(pattern, string)
if match:
return (match.groupdict(),)
return ({},)
class RegexSearchGroupsDataList(ComfyNodeABC):
"""
Searches the string for a match to the pattern and returns a LIST of match groups.
@@ -55,77 +126,6 @@ class RegexSearchGroupsList(ComfyNodeABC):
return ([],)
class RegexGroupDict(ComfyNodeABC):
"""
Searches the string with the given pattern and returns a DICT of named groups.
If no match is found, it returns an empty DICT.
"""
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"string": (IO.STRING, {}),
"pattern": (IO.STRING, {}),
}
}
RETURN_TYPES = ("DICT",)
CATEGORY = "Basic/STRING/regex"
DESCRIPTION = cleandoc(__doc__ or "")
FUNCTION = "groupdict"
def groupdict(self, pattern: str, string: str) -> tuple[dict]:
match = re.search(pattern, string)
if match:
return (match.groupdict(),)
return ({},)
class RegexFindallDataList(ComfyNodeABC):
"""
Returns all non-overlapping matches of a pattern in the string as a list of strings.
"""
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"string": (IO.STRING, {}),
"pattern": (IO.STRING, {}),
}
}
RETURN_TYPES = (IO.STRING,)
CATEGORY = "Basic/STRING/regex"
DESCRIPTION = cleandoc(__doc__ or "")
FUNCTION = "findall"
OUTPUT_IS_LIST = (True,)
def findall(self, pattern: str, string: str) -> tuple[list[str]]:
return (re.findall(pattern, string),)
class RegexFindallList(ComfyNodeABC):
"""
Returns all non-overlapping matches of a pattern in the string as a list of strings.
"""
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"string": (IO.STRING, {}),
"pattern": (IO.STRING, {}),
}
}
RETURN_TYPES = ("LIST",)
CATEGORY = "Basic/STRING/regex"
DESCRIPTION = cleandoc(__doc__ or "")
FUNCTION = "findall"
def findall(self, pattern: str, string: str) -> tuple[list[str]]:
return (re.findall(pattern, string),)
class RegexSplitDataList(ComfyNodeABC):
"""
Splits the string at each match of the pattern and returns a list of substrings.
@@ -220,11 +220,11 @@ class RegexTest(ComfyNodeABC):
NODE_CLASS_MAPPINGS = {
"Basic data handling: RegexSearchGroupsDataList": RegexSearchGroupsDataList,
"Basic data handling: RegexSearchGroupsList": RegexSearchGroupsList,
"Basic data handling: RegexGroupDict": RegexGroupDict,
"Basic data handling: RegexFindallDataList": RegexFindallDataList,
"Basic data handling: RegexFindallList": RegexFindallList,
"Basic data handling: RegexGroupDict": RegexGroupDict,
"Basic data handling: RegexSearchGroupsDataList": RegexSearchGroupsDataList,
"Basic data handling: RegexSearchGroupsList": RegexSearchGroupsList,
"Basic data handling: RegexSplitDataList": RegexSplitDataList,
"Basic data handling: RegexSplitList": RegexSplitList,
"Basic data handling: RegexSub": RegexSub,
@@ -232,11 +232,11 @@ NODE_CLASS_MAPPINGS = {
}
NODE_DISPLAY_NAME_MAPPINGS = {
"Basic data handling: RegexSearchGroupsDataList": "search groups (data list)",
"Basic data handling: RegexSearchGroupsList": "search groups (LIST)",
"Basic data handling: RegexGroupDict": "search named groups",
"Basic data handling: RegexFindallDataList": "find all (data list)",
"Basic data handling: RegexFindallList": "find all (LIST)",
"Basic data handling: RegexGroupDict": "search named groups",
"Basic data handling: RegexSearchGroupsDataList": "search groups (data list)",
"Basic data handling: RegexSearchGroupsList": "search groups (LIST)",
"Basic data handling: RegexSplitDataList": "split (data list)",
"Basic data handling: RegexSplitList": "split (LIST)",
"Basic data handling: RegexSub": "substitute",