diff --git a/__init__.py b/__init__.py index 5d08677..af7d5a7 100644 --- a/__init__.py +++ b/__init__.py @@ -10,7 +10,7 @@ __author__ = """Basic data handling""" __email__ = "stablellama@tutanota.com" __version__ = "0.0.1" -from .src.basic_data_handling.nodes import NODE_CLASS_MAPPINGS -from .src.basic_data_handling.nodes import NODE_DISPLAY_NAME_MAPPINGS +from .src.basic_data_handling import NODE_CLASS_MAPPINGS +from .src.basic_data_handling import NODE_DISPLAY_NAME_MAPPINGS WEB_DIRECTORY = "./web" diff --git a/src/basic_data_handling/__init__.py b/src/basic_data_handling/__init__.py index e69de29..b59b00b 100644 --- a/src/basic_data_handling/__init__.py +++ b/src/basic_data_handling/__init__.py @@ -0,0 +1,11 @@ +from . import string_nodes, list_nodes, dict_nodes + +NODE_CLASS_MAPPINGS = {} +NODE_CLASS_MAPPINGS.update(string_nodes.NODE_CLASS_MAPPINGS) +NODE_CLASS_MAPPINGS.update(list_nodes.NODE_CLASS_MAPPINGS) +NODE_CLASS_MAPPINGS.update(dict_nodes.NODE_CLASS_MAPPINGS) + +NODE_DISPLAY_NAME_MAPPINGS = {} +NODE_DISPLAY_NAME_MAPPINGS.update(string_nodes.NODE_DISPLAY_NAME_MAPPINGS) +NODE_DISPLAY_NAME_MAPPINGS.update(list_nodes.NODE_DISPLAY_NAME_MAPPINGS) +NODE_DISPLAY_NAME_MAPPINGS.update(dict_nodes.NODE_DISPLAY_NAME_MAPPINGS) diff --git a/src/basic_data_handling/dict_nodes.py b/src/basic_data_handling/dict_nodes.py new file mode 100644 index 0000000..eabd2c3 --- /dev/null +++ b/src/basic_data_handling/dict_nodes.py @@ -0,0 +1,60 @@ +from inspect import cleandoc + +class DictGet: + """ + Retrieves a value from a dictionary using the specified key. + + If the key is not found, the node will return None. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "input_dict": ("DICT",), + "key": ("STRING", {"default": ""}), + } + } + + RETURN_TYPES = ("ANY",) + CATEGORY = "Basic/DICT" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "get" + + def get(self, input_dict, key): + return (input_dict.get(key, None),) + +class DictSet: + """ + Adds or updates a key-value pair in a dictionary. + + This node takes a dictionary, key, and value as inputs, then returns + a modified dictionary with the new key-value pair. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "input_dict": ("DICT",), + "key": ("STRING", {"default": ""}), + "value": ("ANY",), + } + } + + RETURN_TYPES = ("DICT",) + CATEGORY = "Basic/DICT" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "set" + + def set(self, input_dict, key, value): + input_dict[key] = value + return (input_dict,) + +NODE_CLASS_MAPPINGS = { + "DictGet": DictGet, + "DictSet": DictSet, +} + +NODE_DISPLAY_NAME_MAPPINGS = { + "DictGet": "get", + "DictSet": "set", +} diff --git a/src/basic_data_handling/list_nodes.py b/src/basic_data_handling/list_nodes.py new file mode 100644 index 0000000..a4c9a54 --- /dev/null +++ b/src/basic_data_handling/list_nodes.py @@ -0,0 +1,58 @@ +from inspect import cleandoc + +class ListAppend: + """ + Adds an item to the end of a list. + + This node takes a list and any item as inputs, then returns the modified + list with the new item appended. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "input_list": ("LIST",), + "item": ("ANY",), + } + } + + RETURN_TYPES = ("LIST",) + CATEGORY = "Basic/LIST" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "append" + + def append(self, input_list, item): + input_list.append(item) + return (input_list,) + +class ListLength: + """ + Counts the number of items in a list. + + This node takes a list as input and returns its length as an integer. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "input_list": ("LIST",), + } + } + + RETURN_TYPES = ("INT",) + CATEGORY = "Basic/LIST" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "length" + + def length(self, input_list): + return (len(input_list),) + +NODE_CLASS_MAPPINGS = { + "ListAppend": ListAppend, + "ListLength": ListLength, +} + +NODE_DISPLAY_NAME_MAPPINGS = { + "ListAppend": "append", + "ListLength": "length", +} diff --git a/src/basic_data_handling/string_nodes.py b/src/basic_data_handling/string_nodes.py new file mode 100644 index 0000000..c21c3ac --- /dev/null +++ b/src/basic_data_handling/string_nodes.py @@ -0,0 +1,1816 @@ +from inspect import cleandoc + +class StringCapitalize: + """Converts the first character of the input string to uppercase and all other characters to lowercase.""" + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + } + } + + RETURN_TYPES = ("STRING",) + CATEGORY = "Basic/STRING" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "capitalize" + + def capitalize(self, string): + return (string.capitalize(),) + + +class StringCasefold: + """ + Converts text to lowercase in a way optimized for case-insensitive comparisons. + + This node is especially useful when comparing text that might contain special characters. + Unlike standard lowercase, this handles special cases like converting the German 'ß' to "ss". + Use this node when you need the most accurate case-insensitive text matching. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + } + } + + RETURN_TYPES = ("STRING",) + CATEGORY = "Basic/STRING" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "casefold" + + def casefold(self, string): + return (string.casefold(),) + + +class StringCenter: + """ + Centers text within a specified width. + + This node takes a string and centers it within a field of the specified width. + By default, it uses spaces as padding characters, but you can specify any + single character to use as padding. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + "width": ("INT", {"default": 20, "min": 0, "max": 1000}), + }, + "optional": { + "fillchar": ("STRING", {"default": " "}), + } + } + + RETURN_TYPES = ("STRING",) + CATEGORY = "Basic/STRING" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "center" + + def center(self, string, width, fillchar=" "): + # Use only the first character if fillchar is longer than 1 character + if len(fillchar) > 1: + fillchar = fillchar[0] + elif len(fillchar) == 0: + fillchar = " " + + return (string.center(width, fillchar),) + + +class StringConcat: + """Combines two text strings together, joining them end-to-end.""" + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string_a": ("STRING", {"default": "", "defaultInput": True}), + "string_b": ("STRING", {"default": "", "defaultInput": True}), + } + } + + RETURN_TYPES = ("STRING",) + CATEGORY = "Basic/STRING" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "concat" + + def concat(self, string_a, string_b): + return (string_a + string_b,) + + +class StringCount: + """ + Counts occurrences of a substring within a string. + + This node returns the number of times the specified substring appears in the input string. + You can optionally specify start and end positions to limit the search range. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + "substring": ("STRING", {"default": ""}), + }, + "optional": { + "start": ("INT", {"default": 0, "min": 0}), + "end": ("INT", {"default": 0, "min": 0}), + } + } + + RETURN_TYPES = ("INT",) + CATEGORY = "Basic/STRING" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "count" + + def count(self, string, substring, start=0, end=0): + # If end is 0 or negative, count to the end of the string + if end <= 0: + end = len(string) + + return (string.count(substring, start, end),) + + +class StringDecode: + """ + Converts a bytes-like string representation back to a text string. + + This node takes a string representation of bytes (like those produced by the StringEncode node) + and converts it back to a regular text string using the specified encoding. + Useful for processing encoded data received from files or network sources. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "bytes_string": ("STRING", {"default": "b''", "defaultInput": True}), + "encoding": (["utf-8", "ascii", "latin-1", "utf-16", "utf-32", "cp1252"],), + "errors": (["strict", "ignore", "replace", "backslashreplace"],), + } + } + + RETURN_TYPES = ("STRING",) + CATEGORY = "Basic/STRING" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "decode" + + def decode(self, bytes_string, encoding="utf-8", errors="strict"): + try: + # Check if the string is in the form of a bytes literal + if bytes_string.startswith("b'") or bytes_string.startswith('b"'): + # Convert the string representation to actual bytes + # This is a simplified approach and may not handle all cases perfectly + # Remove b prefix and quotes + if bytes_string.startswith("b'") and bytes_string.endswith("'"): + content = bytes_string[2:-1] + elif bytes_string.startswith('b"') and bytes_string.endswith('"'): + content = bytes_string[2:-1] + else: + return (f"Invalid bytes string format: {bytes_string}",) + + # Handle escape sequences + content = content.encode('utf-8').decode('unicode_escape').encode('latin-1') + + # Decode using the specified encoding + result = content.decode(encoding, errors) + return (result,) + else: + return (f"Input is not a bytes string representation: {bytes_string}",) + except Exception as e: + return (f"Decoding error: {str(e)}",) + + +class StringEncode: + """ + Converts a string to bytes using the specified encoding. + + This node encodes text using different character encodings like UTF-8 (default), + ASCII, or others. It's useful for preparing text for file saving or + network transmission in specific formats. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + "encoding": (["utf-8", "ascii", "latin-1", "utf-16", "utf-32", "cp1252"],), + "errors": (["strict", "ignore", "replace", "xmlcharrefreplace", "backslashreplace"],), + } + } + + RETURN_TYPES = ("STRING",) + CATEGORY = "Basic/STRING" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "encode" + + def encode(self, string, encoding="utf-8", errors="strict"): + # Encode the string into bytes and then decode back to a string + # representation for display/storage in ComfyUI + try: + # Encode to bytes + encoded_bytes = string.encode(encoding, errors) + # Convert to string representation for display + result = str(encoded_bytes) + return (result,) + except Exception as e: + return (f"Encoding error: {str(e)}",) + + +class StringEndswith: + """ + Checks if a string ends with the specified suffix. + + This node tests whether the input string ends with a particular substring. + Returns True if the string ends with the specified suffix, otherwise False. + Optional start and end parameters allow you to check only a specific portion of the string. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + "suffix": ("STRING", {"default": ""}), + }, + "optional": { + "start": ("INT", {"default": 0, "min": 0}), + "end": ("INT", {"default": 0, "min": 0}), + } + } + + RETURN_TYPES = ("BOOLEAN",) + CATEGORY = "Basic/STRING" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "endswith" + + def endswith(self, string, suffix, start=0, end=0): + # If end is 0 or negative, check to the end of the string + if end <= 0: + end = len(string) + + return (string.endswith(suffix, start, end),) + + +class StringExpandtabs: + """ + Replaces tab characters with spaces. + + This node replaces all tab characters ('\t') in a string with spaces. + The tab size (number of spaces per tab) can be adjusted, + with a default value of 8 characters. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + }, + "optional": { + "tabsize": ("INT", {"default": 8, "min": 1, "max": 100}), + } + } + + RETURN_TYPES = ("STRING",) + CATEGORY = "Basic/STRING" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "expandtabs" + + def expandtabs(self, string, tabsize=8): + return (string.expandtabs(tabsize),) + + +class StringFind: + """ + Finds the first occurrence of a substring in a string. + + This node searches for the first occurrence of the specified substring within the input string. + Returns the lowest index where the substring is found. If the substring is not found, it returns -1. + Optional start and end parameters allow you to limit the search to a specific portion of the string. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + "substring": ("STRING", {"default": ""}), + }, + "optional": { + "start": ("INT", {"default": 0, "min": 0}), + "end": ("INT", {"default": 0, "min": 0}), + } + } + + RETURN_TYPES = ("INT",) + CATEGORY = "Basic/STRING" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "find" + + def find(self, string, substring, start=0, end=0): + # If end is 0 or negative, search to the end of the string + if end <= 0: + end = len(string) + + return (string.find(substring, start, end),) + + +class StringIn: + """ + Checks if a string contains a specified substring. + + This node implements the 'in' operator for strings. It checks whether the given substring + exists within the input string. Returns True if the substring is found, + otherwise False. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + "substring": ("STRING", {"default": ""}), + } + } + + RETURN_TYPES = ("BOOLEAN",) + CATEGORY = "Basic/STRING" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "contains" + + def contains(self, string, substring): + return (substring in string,) + + +class StringFormatMap: + """ + Formats a string using values from a dictionary. + + This node replaces placeholders in the input string with values from a dictionary. + It uses the same placeholder syntax as the format() method, but takes the values from a dictionary + mapping keys to values. For example, the string "Hello, {name}" with a dictionary {"name": "World"} + would produce "Hello, World". + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "template": ("STRING", {"default": "Hello, {key}", "defaultInput": True}), + "mapping": ("DICT", {"default": {}}), + } + } + + RETURN_TYPES = ("STRING",) + CATEGORY = "Basic/STRING" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "format_map" + + def format_map(self, template, mapping): + try: + result = template.format_map(mapping) + return (result,) + except KeyError as e: + return (f"Key error: {str(e)} not found in mapping",) + except Exception as e: + return (f"Formatting error: {str(e)}",) + + +class StringIsAlnum: + """ + Checks if all characters in the string are alphanumeric. + + This node returns True if all characters in the string are alphanumeric + (letters or numbers) and there is at least one character, otherwise False. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + } + } + + RETURN_TYPES = ("BOOLEAN",) + CATEGORY = "Basic/STRING/is" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "isalnum" + + def isalnum(self, string): + return (string.isalnum(),) + + +class StringIsAlpha: + """ + Checks if all characters in the string are alphabetic. + + This node returns True if all characters in the string are alphabetic + (letters) and there is at least one character, otherwise False. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + } + } + + RETURN_TYPES = ("BOOLEAN",) + CATEGORY = "Basic/STRING/is" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "isalpha" + + def isalpha(self, string): + return (string.isalpha(),) + + +class StringIsAscii: + """ + Checks if all characters in the string are ASCII characters. + + This node returns True if all characters in the string are in the ASCII character + set and there is at least one character, otherwise False. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + } + } + + RETURN_TYPES = ("BOOLEAN",) + CATEGORY = "Basic/STRING/is" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "isascii" + + def isascii(self, string): + return (string.isascii(),) + + +class StringIsDecimal: + """ + Checks if all characters in the string are decimal characters. + + This node returns True if all characters in the string are decimal + characters and there is at least one character, otherwise False. + Decimal characters include digit characters and characters that can be + used to form decimal numbers in various locales. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + } + } + + RETURN_TYPES = ("BOOLEAN",) + CATEGORY = "Basic/STRING/is" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "isdecimal" + + def isdecimal(self, string): + return (string.isdecimal(),) + + +class StringIsDigit: + """ + Checks if all characters in the string are digits. + + This node returns True if all characters in the string are digits + and there is at least one character, otherwise False. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + } + } + + RETURN_TYPES = ("BOOLEAN",) + CATEGORY = "Basic/STRING/is" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "isdigit" + + def isdigit(self, string): + return (string.isdigit(),) + + +class StringIsIdentifier: + """ + Checks if the string is a valid identifier in Python. + + This node returns True if the string is a valid Python identifier, + otherwise False. A valid identifier must start with a letter or underscore + and can only contain letters, digits, or underscores. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + } + } + + RETURN_TYPES = ("BOOLEAN",) + CATEGORY = "Basic/STRING/is" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "isidentifier" + + def isidentifier(self, string): + return (string.isidentifier(),) + + +class StringIsLower: + """ + Checks if all characters in the string are lowercase. + + This node returns True if all cased characters in the string are lowercase + and there is at least one cased character, otherwise False. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + } + } + + RETURN_TYPES = ("BOOLEAN",) + CATEGORY = "Basic/STRING/is" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "islower" + + def islower(self, string): + return (string.islower(),) + + +class StringIsNumeric: + """ + Checks if all characters in the string are numeric. + + This node returns True if all characters in the string are numeric + and there is at least one character, otherwise False. Numeric characters include + digit characters and characters that have the Unicode numeric value property. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + } + } + + RETURN_TYPES = ("BOOLEAN",) + CATEGORY = "Basic/STRING/is" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "isnumeric" + + def isnumeric(self, string): + return (string.isnumeric(),) + + +class StringIsPrintable: + """ + Checks if all characters in the string are printable. + + This node returns True if all characters in the string are printable or the string is empty, + otherwise False. Printable characters are those which are not control characters. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + } + } + + RETURN_TYPES = ("BOOLEAN",) + CATEGORY = "Basic/STRING/is" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "isprintable" + + def isprintable(self, string): + return (string.isprintable(),) + + +class StringIsSpace: + """ + Checks if all characters in the string are whitespace. + + This node returns True if all characters in the string are whitespace + and there is at least one character, otherwise False. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + } + } + + RETURN_TYPES = ("BOOLEAN",) + CATEGORY = "Basic/STRING/is" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "isspace" + + def isspace(self, string): + return (string.isspace(),) + + +class StringIsTitle: + """ + Checks if the string is titlecased. + + This node returns True if the string is titlecased and there is at least one + character, otherwise False. A titlecased string has all words start with an + uppercase character and continue with lowercase. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + } + } + + RETURN_TYPES = ("BOOLEAN",) + CATEGORY = "Basic/STRING/is" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "istitle" + + def istitle(self, string): + return (string.istitle(),) + + +class StringIsUpper: + """ + Checks if all characters in the string are uppercase. + + This node returns True if all cased characters in the string are uppercase + and there is at least one cased character, otherwise False. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + } + } + + RETURN_TYPES = ("BOOLEAN",) + CATEGORY = "Basic/STRING/is" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "isupper" + + def isupper(self, string): + return (string.isupper(),) + + +class StringLjust: + """ + Left-aligns the string within a field of a given width. + + This node returns a string left-aligned in a field of the specified width. + If fillchar is provided, it is used as the padding character instead of a space. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + "width": ("INT", {"default": 10, "min": 0}), + }, + "optional": { + "fillchar": ("STRING", {"default": " "}), + } + } + + RETURN_TYPES = ("STRING",) + CATEGORY = "Basic/STRING" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "ljust" + + def ljust(self, string, width, fillchar=" "): + # Ensure fillchar is only one character + if len(fillchar) > 0: + fillchar = fillchar[0] + return (string.ljust(width, fillchar),) + + +class StringLower: + """ + Converts the string to lowercase. + + This node returns a copy of the string with all uppercase characters converted to lowercase. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + } + } + + RETURN_TYPES = ("STRING",) + CATEGORY = "Basic/STRING" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "lower" + + def lower(self, string): + return (string.lower(),) + + +class StringLstrip: + """ + Removes leading characters from the string. + + This node returns a copy of the string with leading characters removed. + If chars is provided, it specifies the set of characters to be removed. + If chars is not provided, whitespace characters are removed. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + }, + "optional": { + "chars": ("STRING", {"default": ""}), + } + } + + RETURN_TYPES = ("STRING",) + CATEGORY = "Basic/STRING" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "lstrip" + + def lstrip(self, string, chars=None): + if chars == "": + chars = None + return (string.lstrip(chars),) + + +class StringReplace: + """ + Replaces occurrences of a substring with another substring. + + This node returns a copy of the string with all occurrences of substring + old replaced by new. If the optional argument count is given, only the + first count occurrences are replaced. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + "old": ("STRING", {"default": ""}), + "new": ("STRING", {"default": ""}), + }, + "optional": { + "count": ("INT", {"default": -1, "min": -1}), + } + } + + RETURN_TYPES = ("STRING",) + CATEGORY = "Basic/STRING" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "replace" + + def replace(self, string, old, new, count=-1): + return (string.replace(old, new, count),) + + +class StringRemoveprefix: + """ + Removes prefix from the string if present. + + This node returns a copy of the string with the specified prefix removed + if the string starts with that prefix, otherwise returns the original string. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + "prefix": ("STRING", {"default": ""}), + } + } + + RETURN_TYPES = ("STRING",) + CATEGORY = "Basic/STRING" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "removeprefix" + + def removeprefix(self, string, prefix): + return (string.removeprefix(prefix),) + + +class StringRemovesuffix: + """ + Removes suffix from the string if present. + + This node returns a copy of the string with the specified suffix removed + if the string ends with that suffix, otherwise returns the original string. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + "suffix": ("STRING", {"default": ""}), + } + } + + RETURN_TYPES = ("STRING",) + CATEGORY = "Basic/STRING" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "removesuffix" + + def removesuffix(self, string, suffix): + return (string.removesuffix(suffix),) + + +class StringRfind: + """ + Finds the highest index of the substring in the string. + + This node searches for the last occurrence of the specified substring within the input string. + Returns the highest index where the substring is found. If the substring is not found, it returns -1. + Optional start and end parameters allow you to limit the search to a specific portion of the string. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + "substring": ("STRING", {"default": ""}), + }, + "optional": { + "start": ("INT", {"default": 0, "min": 0}), + "end": ("INT", {"default": 0, "min": 0}), + } + } + + RETURN_TYPES = ("INT",) + CATEGORY = "Basic/STRING" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "rfind" + + def rfind(self, string, substring, start=0, end=0): + # If end is 0 or negative, search to the end of the string + if end <= 0: + end = len(string) + + return (string.rfind(substring, start, end),) + + +class StringRjust: + """ + Right-aligns the string within a field of a given width. + + This node returns a string right-aligned in a field of the specified width. + If fillchar is provided, it is used as the padding character instead of a space. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + "width": ("INT", {"default": 10, "min": 0}), + }, + "optional": { + "fillchar": ("STRING", {"default": " "}), + } + } + + RETURN_TYPES = ("STRING",) + CATEGORY = "Basic/STRING" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "rjust" + + def rjust(self, string, width, fillchar=" "): + # Ensure fillchar is only one character + if len(fillchar) > 0: + fillchar = fillchar[0] + return (string.rjust(width, fillchar),) + + +class StringRsplit: + """ + Splits the string at the specified separator from the right. + + This node returns a list of strings by splitting the input string at the specified separator, + starting from the right. If maxsplit is provided, at most maxsplit splits are done. + If the separator is not specified or is None, any whitespace string is a separator. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + }, + "optional": { + "sep": ("STRING", {"default": ""}), + "maxsplit": ("INT", {"default": -1, "min": -1}), + } + } + + RETURN_TYPES = ("LIST",) + CATEGORY = "Basic/STRING" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "rsplit" + + def rsplit(self, string, sep=None, maxsplit=-1): + if sep == "": + sep = None + return (string.rsplit(sep, maxsplit),) + + +class StringRstrip: + """ + Removes trailing characters from the string. + + This node returns a copy of the string with trailing characters removed. + If chars is provided, it specifies the set of characters to be removed. + If chars is not provided, whitespace characters are removed. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + }, + "optional": { + "chars": ("STRING", {"default": ""}), + } + } + + RETURN_TYPES = ("STRING",) + CATEGORY = "Basic/STRING" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "rstrip" + + def rstrip(self, string, chars=None): + if chars == "": + chars = None + return (string.rstrip(chars),) + + + +class StringLjust: + """ + Left-aligns the string within a field of a given width. + + This node returns a string left-aligned in a field of the specified width. + If fillchar is provided, it is used as the padding character instead of a space. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + "width": ("INT", {"default": 10, "min": 0}), + }, + "optional": { + "fillchar": ("STRING", {"default": " "}), + } + } + + RETURN_TYPES = ("STRING",) + CATEGORY = "Basic/STRING" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "ljust" + + def ljust(self, string, width, fillchar=" "): + # Ensure fillchar is only one character + if len(fillchar) > 0: + fillchar = fillchar[0] + return (string.ljust(width, fillchar),) + + +class StringLower: + """ + Converts the string to lowercase. + + This node returns a copy of the string with all uppercase characters converted to lowercase. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + } + } + + RETURN_TYPES = ("STRING",) + CATEGORY = "Basic/STRING" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "lower" + + def lower(self, string): + return (string.lower(),) + + +class StringLstrip: + """ + Removes leading characters from the string. + + This node returns a copy of the string with leading characters removed. + If chars is provided, it specifies the set of characters to be removed. + If chars is not provided, whitespace characters are removed. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + }, + "optional": { + "chars": ("STRING", {"default": ""}), + } + } + + RETURN_TYPES = ("STRING",) + CATEGORY = "Basic/STRING" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "lstrip" + + def lstrip(self, string, chars=None): + if chars == "": + chars = None + return (string.lstrip(chars),) + + +class StringReplace: + """ + Replaces occurrences of a substring with another substring. + + This node returns a copy of the string with all occurrences of substring + old replaced by new. If the optional argument count is given, only the + first count occurrences are replaced. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + "old": ("STRING", {"default": ""}), + "new": ("STRING", {"default": ""}), + }, + "optional": { + "count": ("INT", {"default": -1, "min": -1}), + } + } + + RETURN_TYPES = ("STRING",) + CATEGORY = "Basic/STRING" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "replace" + + def replace(self, string, old, new, count=-1): + return (string.replace(old, new, count),) + + +class StringRemoveprefix: + """ + Removes prefix from the string if present. + + This node returns a copy of the string with the specified prefix removed + if the string starts with that prefix, otherwise returns the original string. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + "prefix": ("STRING", {"default": ""}), + } + } + + RETURN_TYPES = ("STRING",) + CATEGORY = "Basic/STRING" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "removeprefix" + + def removeprefix(self, string, prefix): + return (string.removeprefix(prefix),) + + +class StringRemovesuffix: + """ + Removes suffix from the string if present. + + This node returns a copy of the string with the specified suffix removed + if the string ends with that suffix, otherwise returns the original string. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + "suffix": ("STRING", {"default": ""}), + } + } + + RETURN_TYPES = ("STRING",) + CATEGORY = "Basic/STRING" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "removesuffix" + + def removesuffix(self, string, suffix): + return (string.removesuffix(suffix),) + + +class StringRfind: + """ + Finds the highest index of the substring in the string. + + This node searches for the last occurrence of the specified substring within the input string. + Returns the highest index where the substring is found. If the substring is not found, it returns -1. + Optional start and end parameters allow you to limit the search to a specific portion of the string. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + "substring": ("STRING", {"default": ""}), + }, + "optional": { + "start": ("INT", {"default": 0, "min": 0}), + "end": ("INT", {"default": 0, "min": 0}), + } + } + + RETURN_TYPES = ("INT",) + CATEGORY = "Basic/STRING" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "rfind" + + def rfind(self, string, substring, start=0, end=0): + # If end is 0 or negative, search to the end of the string + if end <= 0: + end = len(string) + + return (string.rfind(substring, start, end),) + + +class StringRjust: + """ + Right-aligns the string within a field of a given width. + + This node returns a string right-aligned in a field of the specified width. + If fillchar is provided, it is used as the padding character instead of a space. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + "width": ("INT", {"default": 10, "min": 0}), + }, + "optional": { + "fillchar": ("STRING", {"default": " "}), + } + } + + RETURN_TYPES = ("STRING",) + CATEGORY = "Basic/STRING" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "rjust" + + def rjust(self, string, width, fillchar=" "): + # Ensure fillchar is only one character + if len(fillchar) > 0: + fillchar = fillchar[0] + return (string.rjust(width, fillchar),) + + +class StringRsplit: + """ + Splits the string at the specified separator from the right. + + This node returns a list of strings by splitting the input string at the specified separator, + starting from the right. If maxsplit is provided, at most maxsplit splits are done. + If the separator is not specified or is None, any whitespace string is a separator. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + }, + "optional": { + "sep": ("STRING", {"default": ""}), + "maxsplit": ("INT", {"default": -1, "min": -1}), + } + } + + RETURN_TYPES = ("LIST",) + CATEGORY = "Basic/STRING" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "rsplit" + + def rsplit(self, string, sep=None, maxsplit=-1): + if sep == "": + sep = None + return (string.rsplit(sep, maxsplit),) + + +class StringRstrip: + """ + Removes trailing characters from the string. + + This node returns a copy of the string with trailing characters removed. + If chars is provided, it specifies the set of characters to be removed. + If chars is not provided, whitespace characters are removed. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + }, + "optional": { + "chars": ("STRING", {"default": ""}), + } + } + + RETURN_TYPES = ("STRING",) + CATEGORY = "Basic/STRING" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "rstrip" + + def rstrip(self, string, chars=None): + if chars == "": + chars = None + return (string.rstrip(chars),) + + +class StringLjust: + """ + Left-aligns the string within a field of a given width. + + This node returns a string left-aligned in a field of the specified width. + If fillchar is provided, it is used as the padding character instead of a space. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + "width": ("INT", {"default": 10, "min": 0}), + }, + "optional": { + "fillchar": ("STRING", {"default": " "}), + } + } + + RETURN_TYPES = ("STRING",) + CATEGORY = "Basic/STRING" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "ljust" + + def ljust(self, string, width, fillchar=" "): + # Ensure fillchar is only one character + if len(fillchar) > 0: + fillchar = fillchar[0] + return (string.ljust(width, fillchar),) + + +class StringLower: + """ + Converts the string to lowercase. + + This node returns a copy of the string with all uppercase characters converted to lowercase. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + } + } + + RETURN_TYPES = ("STRING",) + CATEGORY = "Basic/STRING" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "lower" + + def lower(self, string): + return (string.lower(),) + + +class StringLstrip: + """ + Removes leading characters from the string. + + This node returns a copy of the string with leading characters removed. + If chars is provided, it specifies the set of characters to be removed. + If chars is not provided, whitespace characters are removed. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + }, + "optional": { + "chars": ("STRING", {"default": ""}), + } + } + + RETURN_TYPES = ("STRING",) + CATEGORY = "Basic/STRING" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "lstrip" + + def lstrip(self, string, chars=None): + if chars == "": + chars = None + return (string.lstrip(chars),) + + +class StringRemoveprefix: + """ + Removes prefix from the string if present. + + This node returns a copy of the string with the specified prefix removed + if the string starts with that prefix, otherwise returns the original string. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + "prefix": ("STRING", {"default": ""}), + } + } + + RETURN_TYPES = ("STRING",) + CATEGORY = "Basic/STRING" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "removeprefix" + + def removeprefix(self, string, prefix): + return (string.removeprefix(prefix),) + + +class StringRemovesuffix: + """ + Removes suffix from the string if present. + + This node returns a copy of the string with the specified suffix removed + if the string ends with that suffix, otherwise returns the original string. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + "suffix": ("STRING", {"default": ""}), + } + } + + RETURN_TYPES = ("STRING",) + CATEGORY = "Basic/STRING" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "removesuffix" + + def removesuffix(self, string, suffix): + return (string.removesuffix(suffix),) + + +class StringRfind: + """ + Finds the highest index of the substring in the string. + + This node searches for the last occurrence of the specified substring within the input string. + Returns the highest index where the substring is found. If the substring is not found, it returns -1. + Optional start and end parameters allow you to limit the search to a specific portion of the string. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + "substring": ("STRING", {"default": ""}), + }, + "optional": { + "start": ("INT", {"default": 0, "min": 0}), + "end": ("INT", {"default": 0, "min": 0}), + } + } + + RETURN_TYPES = ("INT",) + CATEGORY = "Basic/STRING" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "rfind" + + def rfind(self, string, substring, start=0, end=0): + # If end is 0 or negative, search to the end of the string + if end <= 0: + end = len(string) + + return (string.rfind(substring, start, end),) + + +class StringRjust: + """ + Right-aligns the string within a field of a given width. + + This node returns a string right-aligned in a field of the specified width. + If fillchar is provided, it is used as the padding character instead of a space. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + "width": ("INT", {"default": 10, "min": 0}), + }, + "optional": { + "fillchar": ("STRING", {"default": " "}), + } + } + + RETURN_TYPES = ("STRING",) + CATEGORY = "Basic/STRING" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "rjust" + + def rjust(self, string, width, fillchar=" "): + # Ensure fillchar is only one character + if len(fillchar) > 0: + fillchar = fillchar[0] + return (string.rjust(width, fillchar),) + + +class StringRsplit: + """ + Splits the string at the specified separator from the right. + + This node returns a list of strings by splitting the input string at the specified separator, + starting from the right. If maxsplit is provided, at most maxsplit splits are done. + If the separator is not specified or is None, any whitespace string is a separator. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + }, + "optional": { + "sep": ("STRING", {"default": ""}), + "maxsplit": ("INT", {"default": -1, "min": -1}), + } + } + + RETURN_TYPES = ("LIST",) + CATEGORY = "Basic/STRING" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "rsplit" + + def rsplit(self, string, sep=None, maxsplit=-1): + if sep == "": + sep = None + return (string.rsplit(sep, maxsplit),) + + +class StringRstrip: + """ + Removes trailing characters from the string. + + This node returns a copy of the string with trailing characters removed. + If chars is provided, it specifies the set of characters to be removed. + If chars is not provided, whitespace characters are removed. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + }, + "optional": { + "chars": ("STRING", {"default": ""}), + } + } + + RETURN_TYPES = ("STRING",) + CATEGORY = "Basic/STRING" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "rstrip" + + def rstrip(self, string, chars=None): + if chars == "": + chars = None + return (string.rstrip(chars),) + + +class StringSplit: + """ + Splits the string at the specified separator. + + This node returns a list of strings by splitting the input string at the specified separator. + If maxsplit is provided, at most maxsplit splits are done. + If the separator is not specified or is None, any whitespace string is a separator. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + }, + "optional": { + "sep": ("STRING", {"default": ""}), + "maxsplit": ("INT", {"default": -1, "min": -1}), + } + } + + RETURN_TYPES = ("LIST",) + CATEGORY = "Basic/STRING" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "split" + + def split(self, string, sep=None, maxsplit=-1): + if sep == "": + sep = None + return (string.split(sep, maxsplit),) + + +class StringSplitlines: + """ + Splits the string at line boundaries. + + This node returns a list of the lines in the string, breaking at line boundaries. + If keepends is True, line breaks are included in the resulting list. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + }, + "optional": { + "keepends": ("BOOLEAN", {"default": False}), + } + } + + RETURN_TYPES = ("LIST",) + CATEGORY = "Basic/STRING" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "splitlines" + + def splitlines(self, string, keepends=False): + return (string.splitlines(keepends),) + + +class StringStartswith: + """ + Checks if a string starts with the specified prefix. + + This node tests whether the input string starts with a particular substring. + Returns True if the string starts with the specified prefix, otherwise False. + Optional start and end parameters allow you to check only a specific portion of the string. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + "prefix": ("STRING", {"default": ""}), + }, + "optional": { + "start": ("INT", {"default": 0, "min": 0}), + "end": ("INT", {"default": 0, "min": 0}), + } + } + + RETURN_TYPES = ("BOOLEAN",) + CATEGORY = "Basic/STRING" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "startswith" + + def startswith(self, string, prefix, start=0, end=0): + # If end is 0 or negative, check to the end of the string + if end <= 0: + end = len(string) + + return (string.startswith(prefix, start, end),) + + +class StringStrip: + """ + Removes leading and trailing characters from the string. + + This node returns a copy of the string with both leading and trailing characters removed. + If chars is provided, it specifies the set of characters to be removed. + If chars is not provided, whitespace characters are removed. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + }, + "optional": { + "chars": ("STRING", {"default": ""}), + } + } + + RETURN_TYPES = ("STRING",) + CATEGORY = "Basic/STRING" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "strip" + + def strip(self, string, chars=None): + if chars == "": + chars = None + return (string.strip(chars),) + + +class StringSwapcase: + """ + Swaps case of all characters in the string. + + This node returns a copy of the string with uppercase characters converted to lowercase + and lowercase characters converted to uppercase. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + } + } + + RETURN_TYPES = ("STRING",) + CATEGORY = "Basic/STRING" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "swapcase" + + def swapcase(self, string): + return (string.swapcase(),) + + +class StringTitle: + """ + Converts the string to titlecase. + + This node returns a titlecased version of the string where words start with an uppercase + character and the remaining characters are lowercase. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + } + } + + RETURN_TYPES = ("STRING",) + CATEGORY = "Basic/STRING" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "title" + + def title(self, string): + return (string.title(),) + + +class StringUpper: + """ + Converts the string to uppercase. + + This node returns a copy of the string with all lowercase characters converted to uppercase. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + } + } + + RETURN_TYPES = ("STRING",) + CATEGORY = "Basic/STRING" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "upper" + + def upper(self, string): + return (string.upper(),) + + +class StringZfill: + """ + Pads the string with zeros on the left. + + This node returns a copy of the string left filled with ASCII '0' digits to make a string + of length width. A leading sign prefix ('+'/'-') is handled by inserting the padding + after the sign character rather than before. + """ + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string": ("STRING", {"default": "", "defaultInput": True}), + "width": ("INT", {"default": 10, "min": 0}), + } + } + + RETURN_TYPES = ("STRING",) + CATEGORY = "Basic/STRING" + DESCRIPTION = cleandoc(__doc__ or "") + FUNCTION = "zfill" + + def zfill(self, string, width): + return (string.zfill(width),) + + + +NODE_CLASS_MAPPINGS = { + "StringCapitalize": StringCapitalize, + "StringCasefold": StringCasefold, + "StringCenter": StringCenter, + "StringConcat": StringConcat, + "StringCount": StringCount, + "StringDecode": StringDecode, + "StringEncode": StringEncode, + "StringExpandtabs": StringExpandtabs, + "StringEndswith": StringEndswith, + "StringFind": StringFind, + "StringFormatMap": StringFormatMap, + "StringIsAlnum": StringIsAlnum, + "StringIsAlpha": StringIsAlpha, + "StringIsAscii": StringIsAscii, + "StringIsDecimal": StringIsDecimal, + "StringIsDigit": StringIsDigit, + "StringIsIdentifier": StringIsIdentifier, + "StringIsLower": StringIsLower, + "StringIsNumeric": StringIsNumeric, + "StringIsPrintable": StringIsPrintable, + "StringIsSpace": StringIsSpace, + "StringIsTitle": StringIsTitle, + "StringIsUpper": StringIsUpper, + "StringLjust": StringLjust, + "StringLower": StringLower, + "StringLstrip": StringLstrip, + "StringRemoveprefix": StringRemoveprefix, + "StringRemovesuffix": StringRemovesuffix, + "StringReplace": StringReplace, + "StringRfind": StringRfind, + "StringRjust": StringRjust, + "StringRsplit": StringRsplit, + "StringRstrip": StringRstrip, + "StringSplit": StringSplit, + "StringSplitlines": StringSplitlines, + "StringStartswith": StringStartswith, + "StringStrip": StringStrip, + "StringSwapcase": StringSwapcase, + "StringTitle": StringTitle, + "StringUpper": StringUpper, + "StringZfill": StringZfill, +} + +NODE_DISPLAY_NAME_MAPPINGS = { + "StringCapitalize": "capitalize", + "StringCasefold": "casefold", + "StringCenter": "center", + "StringConcat": "concat", + "StringCount": "count", + "StringDecode": "decode", + "StringEncode": "encode", + "StringExpandtabs": "expandtabs", + "StringEndswith": "endswith", + "StringFind": "find", + "StringFormatMap": "format_map", + "StringIn": "in (contains)", + "StringIsAlnum": "isalnum", + "StringIsAlpha": "isalpha", + "StringIsAscii": "isascii", + "StringIsDecimal": "isdecimal", + "StringIsDigit": "isdigit", + "StringIsIdentifier": "isidentifier", + "StringIsLower": "islower", + "StringIsNumeric": "isnumeric", + "StringIsPrintable": "isprintable", + "StringIsSpace": "isspace", + "StringIsTitle": "istitle", + "StringIsUpper": "isupper", + "StringLjust": "ljust", + "StringLower": "lower", + "StringLstrip": "lstrip", + "StringRemoveprefix": "removeprefix", + "StringRemovesuffix": "removesuffix", + "StringReplace": "replace", + "StringRfind": "rfind", + "StringRjust": "rjust", + "StringRsplit": "rsplit", + "StringRstrip": "rstrip", + "StringSplit": "split", + "StringSplitlines": "splitlines", + "StringStartswith": "startswith", + "StringStrip": "strip", + "StringSwapcase": "swapcase", + "StringTitle": "title", + "StringUpper": "upper", + "StringZfill": "zfill", +}