funcnodes-basic 0.1.4__py3-none-any.whl → 0.1.6__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.
@@ -1,11 +1,12 @@
1
- from funcnodes import Shelf
1
+ from funcnodes_core import Shelf
2
2
  from .logic import NODE_SHELF as logic_shelf
3
- from .math import NODE_SHELF as math_shelf
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
- __version__ = "0.1.4"
8
+
9
+ __version__ = "0.1.6"
9
10
 
10
11
  NODE_SHELF = Shelf(
11
12
  nodes=[],
funcnodes_basic/dicts.py CHANGED
@@ -1,7 +1,8 @@
1
1
  """
2
2
  work with python dictionaries
3
3
  """
4
- import funcnodes as fn
4
+
5
+ import funcnodes_core as fn
5
6
  from typing import Any, List, Tuple
6
7
 
7
8
 
@@ -85,7 +86,8 @@ def dict_from_keys_values(keys: List[Any], values: List[Any]) -> dict:
85
86
  ],
86
87
  )
87
88
  def dict_to_list(dictionary: dict) -> Tuple[List[Any], List[Any]]:
88
- return list(dictionary.items())
89
+ keys, values = zip(*dictionary.items())
90
+ return list(keys), list(values)
89
91
 
90
92
 
91
93
  NODE_SHELF = fn.Shelf(
funcnodes_basic/lists.py CHANGED
@@ -1,5 +1,5 @@
1
1
  from typing import List, Union, Any
2
- import funcnodes as fn
2
+ import funcnodes_core as fn
3
3
 
4
4
 
5
5
  @fn.NodeDecorator(
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
- self.collection.append(input)
105
- self.outputs["output"].value = self.collection
106
-
107
-
108
- NODE_SHELF = fn.Shelf(
109
- nodes=[IfNode, WhileNode, WaitNode, ForNode, CollectorNode],
110
- subshelves=[],
111
- name="Logic",
112
- description="Control flow and decision making nodes.",
113
- )
1
+ """Logic Nodes for control flow and decision making."""
2
+
3
+ from funcnodes_core.node import Node, TriggerStack
4
+ from typing import Any, List, Optional
5
+ from funcnodes_core.io import NodeInput, NodeOutput, NoValue
6
+ import asyncio
7
+
8
+ import funcnodes_core 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
+ )