-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjoin_text.py
67 lines (59 loc) · 1.9 KB
/
join_text.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
class JoinTexts:
"""
A node that joins two input strings with a newline.
Class methods
-------------
INPUT_TYPES (dict):
Defines input parameters of nodes.
Attributes
----------
RETURN_TYPES (`tuple`):
The type of each element in the output tuple.
FUNCTION (`str`):
The name of the entry-point method.
CATEGORY (`str`):
The category the node should appear in the UI.
"""
FUNCTION = "execute"
RETURN_TYPES = ("STRING",)
CATEGORY = "🧑✈️ Captain/🛠️ Utilities"
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"first_string": ("STRING", {
"multiline": True,
"default": "First String"
}),
"second_string": ("STRING", {
"multiline": True,
"default": "Second String"
}),
"delimiter": ("STRING", {
"multiline": False,
"default": ", "
}),
"add_newline": ("BOOLEAN", {
"default": False
}),
},
}
def execute(self, first_string, second_string, delimiter, add_newline):
""" Joins two strings with a newline.
Parameters:
first_string (str): The first string to join.
second_string (str): The second string to join.
delimiter (str): The delimiter used to join the two strings.
add_newline (bool): Adds a newline after the delimiter.
Returns:
tuple: Contains the joined strings.
"""
if add_newline:
delimiter += "\n"
return (f"{first_string}{delimiter}{second_string}",)
NODE_CLASS_MAPPINGS = {
"Captain__JoinTexts": JoinTexts
}
NODE_DISPLAY_NAME_MAPPINGS = {
"Captain__JoinTexts": "🧑✈️ Join Texts"
}