funcnodes-basic 0.1.4__py3-none-any.whl → 0.1.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- funcnodes_basic/__init__.py +3 -2
- funcnodes_basic/dicts.py +2 -1
- funcnodes_basic/logic.py +114 -113
- funcnodes_basic/{math.py → math_nodes.py} +684 -684
- {funcnodes_basic-0.1.4.dist-info → funcnodes_basic-0.1.5.dist-info}/METADATA +1 -1
- funcnodes_basic-0.1.5.dist-info/RECORD +10 -0
- funcnodes_basic-0.1.5.dist-info/entry_points.txt +4 -0
- funcnodes_basic-0.1.4.dist-info/RECORD +0 -9
- {funcnodes_basic-0.1.4.dist-info → funcnodes_basic-0.1.5.dist-info}/WHEEL +0 -0
funcnodes_basic/__init__.py
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
from funcnodes import Shelf
|
2
2
|
from .logic import NODE_SHELF as logic_shelf
|
3
|
-
from .
|
3
|
+
from .math_nodes import NODE_SHELF as math_shelf
|
4
4
|
from .lists import NODE_SHELF as lists_shelf
|
5
5
|
from .strings import NODE_SHELF as strings_shelf
|
6
6
|
from .dicts import NODE_SHELF as dicts_shelf
|
7
7
|
|
8
|
-
|
8
|
+
|
9
|
+
__version__ = "0.1.5"
|
9
10
|
|
10
11
|
NODE_SHELF = Shelf(
|
11
12
|
nodes=[],
|
funcnodes_basic/dicts.py
CHANGED
@@ -85,7 +85,8 @@ def dict_from_keys_values(keys: List[Any], values: List[Any]) -> dict:
|
|
85
85
|
],
|
86
86
|
)
|
87
87
|
def dict_to_list(dictionary: dict) -> Tuple[List[Any], List[Any]]:
|
88
|
-
|
88
|
+
keys, values = zip(*dictionary.items())
|
89
|
+
return list(keys), list(values)
|
89
90
|
|
90
91
|
|
91
92
|
NODE_SHELF = fn.Shelf(
|
funcnodes_basic/logic.py
CHANGED
@@ -1,113 +1,114 @@
|
|
1
|
-
"""Logic Nodes for control flow and decision making."""
|
2
|
-
|
3
|
-
from funcnodes.node import Node, TriggerStack
|
4
|
-
from typing import Any, List, Optional, Union
|
5
|
-
from funcnodes.io import NodeInput, NodeOutput, NoValue
|
6
|
-
import asyncio
|
7
|
-
|
8
|
-
import funcnodes as fn
|
9
|
-
|
10
|
-
|
11
|
-
class IfNode(Node):
|
12
|
-
node_id = "if_node"
|
13
|
-
node_name = "If"
|
14
|
-
on_true = NodeOutput(id="on_true", type=Any)
|
15
|
-
on_false = NodeOutput(id="on_false", type=Any)
|
16
|
-
condition = NodeInput(id="condition", type=bool)
|
17
|
-
input = NodeInput(id="input", type=Any)
|
18
|
-
|
19
|
-
async def func(self, condition: bool, input: Any) -> None:
|
20
|
-
if condition:
|
21
|
-
self.outputs["on_true"].value = input
|
22
|
-
else:
|
23
|
-
self.outputs["on_false"].value = input
|
24
|
-
|
25
|
-
|
26
|
-
class WhileNode(Node):
|
27
|
-
node_id = "while_node"
|
28
|
-
node_name = "While"
|
29
|
-
condition = NodeInput(id="condition", type=bool)
|
30
|
-
input = NodeInput(id="input", type=Any)
|
31
|
-
do = NodeOutput(id="do", type=Any)
|
32
|
-
done = NodeOutput(id="done", type=Any)
|
33
|
-
|
34
|
-
async def func(self, condition: bool, input: Any) -> None:
|
35
|
-
if self.inputs["condition"].value:
|
36
|
-
self.outputs["do"].value = input
|
37
|
-
triggerstack = TriggerStack()
|
38
|
-
await self.outputs["do"].trigger(triggerstack)
|
39
|
-
self.request_trigger()
|
40
|
-
else:
|
41
|
-
self.outputs["done"].value = input
|
42
|
-
|
43
|
-
|
44
|
-
class WaitNode(Node):
|
45
|
-
node_id = "wait_node"
|
46
|
-
node_name = "Wait"
|
47
|
-
delay = NodeInput(
|
48
|
-
id="delay",
|
49
|
-
type=float,
|
50
|
-
required=True,
|
51
|
-
default=1.0,
|
52
|
-
does_trigger=False,
|
53
|
-
render_options={"step": "0.1"},
|
54
|
-
value_options={"min": 0.0},
|
55
|
-
)
|
56
|
-
input = NodeInput(id="input", type=Any)
|
57
|
-
output = NodeOutput(id="output", type=Any)
|
58
|
-
|
59
|
-
async def func(self, delay: float, input: Any) -> None:
|
60
|
-
await asyncio.sleep(delay)
|
61
|
-
self.outputs["output"].value = input
|
62
|
-
|
63
|
-
|
64
|
-
class ForNode(Node):
|
65
|
-
node_id = "for_node"
|
66
|
-
node_name = "For"
|
67
|
-
input = NodeInput(id="input", type=List[Any])
|
68
|
-
do = NodeOutput(id="do", type=Any)
|
69
|
-
collector = NodeInput(id="collector", type=Any, does_trigger=False, required=False)
|
70
|
-
done = NodeOutput(id="done", type=List[Any])
|
71
|
-
|
72
|
-
async def func(self, input: list, collector: Optional[Any] = None) -> None:
|
73
|
-
results = []
|
74
|
-
self.outputs["done"].value = NoValue
|
75
|
-
for i in input:
|
76
|
-
self.outputs["do"].set_value(i, does_trigger=False)
|
77
|
-
triggerstack = TriggerStack()
|
78
|
-
await self.outputs["do"].trigger(triggerstack)
|
79
|
-
v = self.inputs["collector"].value
|
80
|
-
if v is not NoValue:
|
81
|
-
results.append(v)
|
82
|
-
self.inputs["collector"].value = NoValue
|
83
|
-
self.outputs["done"].value = results
|
84
|
-
|
85
|
-
|
86
|
-
class CollectorNode(Node):
|
87
|
-
node_id = "collector_node"
|
88
|
-
node_name = "Collector"
|
89
|
-
|
90
|
-
reset = NodeInput(id="reset", type=Any, does_trigger=True, required=False)
|
91
|
-
input = NodeInput(id="input", type=Any)
|
92
|
-
|
93
|
-
output = NodeOutput(id="output", type=List[Any])
|
94
|
-
default_reset_inputs_on_trigger = True
|
95
|
-
|
96
|
-
def __init__(self, *args, **kwargs):
|
97
|
-
super().__init__(*args, **kwargs)
|
98
|
-
self.collection = []
|
99
|
-
|
100
|
-
async def func(self, input: Any, reset: Any = NoValue) -> None:
|
101
|
-
if reset != NoValue:
|
102
|
-
self.collection = []
|
103
|
-
|
104
|
-
|
105
|
-
self.
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
1
|
+
"""Logic Nodes for control flow and decision making."""
|
2
|
+
|
3
|
+
from funcnodes.node import Node, TriggerStack
|
4
|
+
from typing import Any, List, Optional, Union
|
5
|
+
from funcnodes.io import NodeInput, NodeOutput, NoValue
|
6
|
+
import asyncio
|
7
|
+
|
8
|
+
import funcnodes as fn
|
9
|
+
|
10
|
+
|
11
|
+
class IfNode(Node):
|
12
|
+
node_id = "if_node"
|
13
|
+
node_name = "If"
|
14
|
+
on_true = NodeOutput(id="on_true", type=Any)
|
15
|
+
on_false = NodeOutput(id="on_false", type=Any)
|
16
|
+
condition = NodeInput(id="condition", type=bool)
|
17
|
+
input = NodeInput(id="input", type=Any)
|
18
|
+
|
19
|
+
async def func(self, condition: bool, input: Any) -> None:
|
20
|
+
if condition:
|
21
|
+
self.outputs["on_true"].value = input
|
22
|
+
else:
|
23
|
+
self.outputs["on_false"].value = input
|
24
|
+
|
25
|
+
|
26
|
+
class WhileNode(Node):
|
27
|
+
node_id = "while_node"
|
28
|
+
node_name = "While"
|
29
|
+
condition = NodeInput(id="condition", type=bool)
|
30
|
+
input = NodeInput(id="input", type=Any)
|
31
|
+
do = NodeOutput(id="do", type=Any)
|
32
|
+
done = NodeOutput(id="done", type=Any)
|
33
|
+
|
34
|
+
async def func(self, condition: bool, input: Any) -> None:
|
35
|
+
if self.inputs["condition"].value:
|
36
|
+
self.outputs["do"].value = input
|
37
|
+
triggerstack = TriggerStack()
|
38
|
+
await self.outputs["do"].trigger(triggerstack)
|
39
|
+
self.request_trigger()
|
40
|
+
else:
|
41
|
+
self.outputs["done"].value = input
|
42
|
+
|
43
|
+
|
44
|
+
class WaitNode(Node):
|
45
|
+
node_id = "wait_node"
|
46
|
+
node_name = "Wait"
|
47
|
+
delay = NodeInput(
|
48
|
+
id="delay",
|
49
|
+
type=float,
|
50
|
+
required=True,
|
51
|
+
default=1.0,
|
52
|
+
does_trigger=False,
|
53
|
+
render_options={"step": "0.1"},
|
54
|
+
value_options={"min": 0.0},
|
55
|
+
)
|
56
|
+
input = NodeInput(id="input", type=Any)
|
57
|
+
output = NodeOutput(id="output", type=Any)
|
58
|
+
|
59
|
+
async def func(self, delay: float, input: Any) -> None:
|
60
|
+
await asyncio.sleep(delay)
|
61
|
+
self.outputs["output"].value = input
|
62
|
+
|
63
|
+
|
64
|
+
class ForNode(Node):
|
65
|
+
node_id = "for_node"
|
66
|
+
node_name = "For"
|
67
|
+
input = NodeInput(id="input", type=List[Any])
|
68
|
+
do = NodeOutput(id="do", type=Any)
|
69
|
+
collector = NodeInput(id="collector", type=Any, does_trigger=False, required=False)
|
70
|
+
done = NodeOutput(id="done", type=List[Any])
|
71
|
+
|
72
|
+
async def func(self, input: list, collector: Optional[Any] = None) -> None:
|
73
|
+
results = []
|
74
|
+
self.outputs["done"].value = NoValue
|
75
|
+
for i in input:
|
76
|
+
self.outputs["do"].set_value(i, does_trigger=False)
|
77
|
+
triggerstack = TriggerStack()
|
78
|
+
await self.outputs["do"].trigger(triggerstack)
|
79
|
+
v = self.inputs["collector"].value
|
80
|
+
if v is not NoValue:
|
81
|
+
results.append(v)
|
82
|
+
self.inputs["collector"].value = NoValue
|
83
|
+
self.outputs["done"].value = results
|
84
|
+
|
85
|
+
|
86
|
+
class CollectorNode(Node):
|
87
|
+
node_id = "collector_node"
|
88
|
+
node_name = "Collector"
|
89
|
+
|
90
|
+
reset = NodeInput(id="reset", type=Any, does_trigger=True, required=False)
|
91
|
+
input = NodeInput(id="input", type=Any)
|
92
|
+
|
93
|
+
output = NodeOutput(id="output", type=List[Any])
|
94
|
+
default_reset_inputs_on_trigger = True
|
95
|
+
|
96
|
+
def __init__(self, *args, **kwargs):
|
97
|
+
super().__init__(*args, **kwargs)
|
98
|
+
self.collection = []
|
99
|
+
|
100
|
+
async def func(self, input: Any, reset: Any = NoValue) -> None:
|
101
|
+
if reset != NoValue:
|
102
|
+
self.collection = []
|
103
|
+
self.inputs["reset"].value = NoValue
|
104
|
+
|
105
|
+
self.collection.append(input)
|
106
|
+
self.outputs["output"].value = self.collection
|
107
|
+
|
108
|
+
|
109
|
+
NODE_SHELF = fn.Shelf(
|
110
|
+
nodes=[IfNode, WhileNode, WaitNode, ForNode, CollectorNode],
|
111
|
+
subshelves=[],
|
112
|
+
name="Logic",
|
113
|
+
description="Control flow and decision making nodes.",
|
114
|
+
)
|