funcnodes-basic 0.2.3__py3-none-any.whl → 1.0.0__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 -1
- funcnodes_basic/logic.py +29 -6
- funcnodes_basic/pyobjects.py +183 -0
- {funcnodes_basic-0.2.3.dist-info → funcnodes_basic-1.0.0.dist-info}/METADATA +2 -2
- {funcnodes_basic-0.2.3.dist-info → funcnodes_basic-1.0.0.dist-info}/RECORD +9 -8
- {funcnodes_basic-0.2.3.dist-info → funcnodes_basic-1.0.0.dist-info}/WHEEL +0 -0
- {funcnodes_basic-0.2.3.dist-info → funcnodes_basic-1.0.0.dist-info}/entry_points.txt +0 -0
- {funcnodes_basic-0.2.3.dist-info → funcnodes_basic-1.0.0.dist-info}/licenses/LICENSE +0 -0
- {funcnodes_basic-0.2.3.dist-info → funcnodes_basic-1.0.0.dist-info}/top_level.txt +0 -0
funcnodes_basic/__init__.py
CHANGED
@@ -6,8 +6,9 @@ from .strings import NODE_SHELF as strings_shelf
|
|
6
6
|
from .dicts import NODE_SHELF as dicts_shelf
|
7
7
|
from .input import NODE_SHELF as input_shelf
|
8
8
|
from .dataclass import NODE_SHELF as dataclass_shelf
|
9
|
+
from .pyobjects import NODE_SHELF as pyobjects_shelf
|
9
10
|
|
10
|
-
__version__ = "0.
|
11
|
+
__version__ = "1.0.0"
|
11
12
|
|
12
13
|
NODE_SHELF = Shelf(
|
13
14
|
nodes=[],
|
@@ -15,6 +16,7 @@ NODE_SHELF = Shelf(
|
|
15
16
|
input_shelf,
|
16
17
|
lists_shelf,
|
17
18
|
dicts_shelf,
|
19
|
+
pyobjects_shelf,
|
18
20
|
dataclass_shelf,
|
19
21
|
strings_shelf,
|
20
22
|
math_shelf,
|
funcnodes_basic/logic.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"""Logic Nodes for control flow and decision making."""
|
2
2
|
|
3
|
-
from funcnodes_core.node import Node
|
3
|
+
from funcnodes_core.node import Node
|
4
4
|
from typing import Any, List, Optional
|
5
5
|
from funcnodes_core.io import NodeInput, NodeOutput, NoValue
|
6
6
|
import asyncio
|
@@ -35,8 +35,19 @@ class WhileNode(Node):
|
|
35
35
|
async def func(self, condition: bool, input: Any) -> None:
|
36
36
|
if self.inputs["condition"].value:
|
37
37
|
self.outputs["do"].value = input
|
38
|
-
|
39
|
-
|
38
|
+
datapaths = [
|
39
|
+
ip.datapath
|
40
|
+
for ip in self.outputs["do"].connections
|
41
|
+
if ip.datapath is not None
|
42
|
+
]
|
43
|
+
|
44
|
+
while datapaths:
|
45
|
+
for dp in datapaths:
|
46
|
+
if dp.done(breaking_nodes=[self]):
|
47
|
+
datapaths.remove(dp)
|
48
|
+
break
|
49
|
+
else:
|
50
|
+
await asyncio.sleep(0.1)
|
40
51
|
self.request_trigger()
|
41
52
|
else:
|
42
53
|
self.outputs["done"].value = input
|
@@ -94,9 +105,21 @@ class ForNode(Node):
|
|
94
105
|
pass
|
95
106
|
|
96
107
|
for i in self.progress(input, desc="Iterating", unit="it", total=iplen):
|
97
|
-
self.outputs["do"].set_value(i, does_trigger=
|
98
|
-
|
99
|
-
|
108
|
+
self.outputs["do"].set_value(i, does_trigger=True)
|
109
|
+
datapaths = [
|
110
|
+
ip.datapath
|
111
|
+
for ip in self.outputs["do"].connections
|
112
|
+
if ip.datapath is not None
|
113
|
+
]
|
114
|
+
|
115
|
+
while datapaths:
|
116
|
+
for dp in datapaths:
|
117
|
+
if dp.done(breaking_nodes=[self]):
|
118
|
+
datapaths.remove(dp)
|
119
|
+
break
|
120
|
+
else:
|
121
|
+
await asyncio.sleep(0.1)
|
122
|
+
|
100
123
|
v = self.inputs["collector"].value
|
101
124
|
if v is not NoValue:
|
102
125
|
results.append(v)
|
@@ -0,0 +1,183 @@
|
|
1
|
+
"""Utilities that expose common Python object interactions as nodes."""
|
2
|
+
|
3
|
+
from __future__ import annotations
|
4
|
+
|
5
|
+
from typing import Any, List, Annotated, Dict
|
6
|
+
|
7
|
+
import funcnodes_core as fn
|
8
|
+
from funcnodes_core.io import InputMeta, OutputMeta
|
9
|
+
|
10
|
+
|
11
|
+
def _list_public_attributes(obj: Any) -> List[str]:
|
12
|
+
"""Return a sorted list of the object's non-private attribute names."""
|
13
|
+
if obj is None:
|
14
|
+
return []
|
15
|
+
try:
|
16
|
+
attributes = dir(obj)
|
17
|
+
except Exception: # pragma: no cover - dir() rarely raises but stay defensive
|
18
|
+
return []
|
19
|
+
# Sorting keeps the dropdown stable for UI components that rely on deterministic
|
20
|
+
# value ordering across reruns.
|
21
|
+
return sorted(attr for attr in attributes if not attr.startswith("_"))
|
22
|
+
|
23
|
+
|
24
|
+
def _ensure_non_private(attribute: str) -> None:
|
25
|
+
"""Reject attribute names that appear private."""
|
26
|
+
|
27
|
+
if attribute.startswith("_"):
|
28
|
+
raise AttributeError(
|
29
|
+
f"Access to private attribute '{attribute}' is not permitted by this node."
|
30
|
+
)
|
31
|
+
|
32
|
+
|
33
|
+
@fn.NodeDecorator(
|
34
|
+
id="pyobject_get_attribute",
|
35
|
+
name="Get Attribute",
|
36
|
+
description="Retrieve the value of a non-private attribute from a Python object.",
|
37
|
+
# default_io_options=_attribute_io_options(),
|
38
|
+
)
|
39
|
+
def get_attribute(
|
40
|
+
obj: Annotated[
|
41
|
+
Any,
|
42
|
+
InputMeta(
|
43
|
+
description="Python object that exposes the desired attribute.",
|
44
|
+
on={
|
45
|
+
"after_set_value": fn.decorator.update_other_io_options(
|
46
|
+
"attribute",
|
47
|
+
_list_public_attributes,
|
48
|
+
)
|
49
|
+
}
|
50
|
+
),
|
51
|
+
],
|
52
|
+
attribute: Annotated[
|
53
|
+
str,
|
54
|
+
InputMeta(
|
55
|
+
description="Name of the attribute to retrieve; private attributes are rejected.",
|
56
|
+
),
|
57
|
+
],
|
58
|
+
) -> Annotated[
|
59
|
+
Any,
|
60
|
+
OutputMeta(
|
61
|
+
description="Value read from the requested attribute.",
|
62
|
+
),
|
63
|
+
]:
|
64
|
+
"""Return the value of the selected non-private attribute for the provided object."""
|
65
|
+
_ensure_non_private(attribute)
|
66
|
+
if not hasattr(obj, attribute):
|
67
|
+
raise AttributeError(
|
68
|
+
f"Attribute '{attribute}' is not available on object of type {type(obj).__name__}."
|
69
|
+
)
|
70
|
+
# getattr performs the actual attribute retrieval once validation is complete.
|
71
|
+
return getattr(obj, attribute)
|
72
|
+
|
73
|
+
|
74
|
+
@fn.NodeDecorator(
|
75
|
+
id="pyobject_has_attribute",
|
76
|
+
name="Has Attribute",
|
77
|
+
description="Check whether an object exposes a given attribute.",
|
78
|
+
)
|
79
|
+
def has_attribute(
|
80
|
+
obj: Annotated[
|
81
|
+
Any,
|
82
|
+
InputMeta(
|
83
|
+
description="Python object that may expose the attribute.",
|
84
|
+
),
|
85
|
+
],
|
86
|
+
attribute: Annotated[
|
87
|
+
str,
|
88
|
+
InputMeta(
|
89
|
+
description="Attribute name to probe; private attributes are rejected.",
|
90
|
+
),
|
91
|
+
],
|
92
|
+
) -> Annotated[
|
93
|
+
bool,
|
94
|
+
OutputMeta(description="True if the attribute exists on the object."),
|
95
|
+
]:
|
96
|
+
"""Return True when the object defines the requested attribute."""
|
97
|
+
|
98
|
+
return hasattr(obj, attribute)
|
99
|
+
|
100
|
+
|
101
|
+
@fn.NodeDecorator(
|
102
|
+
id="pyobject_set_attribute",
|
103
|
+
name="Set Attribute",
|
104
|
+
description="Assign a new value to a non-private attribute on a Python object.",
|
105
|
+
)
|
106
|
+
def set_attribute(
|
107
|
+
obj: Annotated[
|
108
|
+
Any,
|
109
|
+
InputMeta(
|
110
|
+
description="Python object whose attribute should be updated.",
|
111
|
+
),
|
112
|
+
],
|
113
|
+
attribute: Annotated[
|
114
|
+
str,
|
115
|
+
InputMeta(
|
116
|
+
description="Attribute name that will receive the new value.",
|
117
|
+
),
|
118
|
+
],
|
119
|
+
value: Annotated[
|
120
|
+
Any,
|
121
|
+
InputMeta(description="Value to assign to the attribute."),
|
122
|
+
],
|
123
|
+
) -> Annotated[
|
124
|
+
Any,
|
125
|
+
OutputMeta(description="The original object after assignment."),
|
126
|
+
]:
|
127
|
+
"""Set an attribute on the provided object and return the object for chaining."""
|
128
|
+
|
129
|
+
_ensure_non_private(attribute)
|
130
|
+
setattr(obj, attribute, value)
|
131
|
+
return obj
|
132
|
+
|
133
|
+
|
134
|
+
@fn.NodeDecorator(
|
135
|
+
id="pyobject_delete_attribute",
|
136
|
+
name="Delete Attribute",
|
137
|
+
description="Remove a non-private attribute from a Python object.",
|
138
|
+
)
|
139
|
+
def delete_attribute(
|
140
|
+
obj: Annotated[
|
141
|
+
Any,
|
142
|
+
InputMeta(
|
143
|
+
description="Python object whose attribute should be removed.",
|
144
|
+
on={
|
145
|
+
"after_set_value": fn.decorator.update_other_io_options(
|
146
|
+
"attribute",
|
147
|
+
_list_public_attributes,
|
148
|
+
)
|
149
|
+
}
|
150
|
+
),
|
151
|
+
],
|
152
|
+
attribute: Annotated[
|
153
|
+
str,
|
154
|
+
InputMeta(
|
155
|
+
description="Attribute name to remove from the object.",
|
156
|
+
),
|
157
|
+
],
|
158
|
+
) -> Annotated[
|
159
|
+
Any,
|
160
|
+
OutputMeta(description="The original object after deletion."),
|
161
|
+
]:
|
162
|
+
"""Delete an attribute from the object and return the mutated object."""
|
163
|
+
|
164
|
+
_ensure_non_private(attribute)
|
165
|
+
if not hasattr(obj, attribute):
|
166
|
+
raise AttributeError(
|
167
|
+
f"Attribute '{attribute}' is not available on object of type {type(obj).__name__}."
|
168
|
+
)
|
169
|
+
delattr(obj, attribute)
|
170
|
+
return obj
|
171
|
+
|
172
|
+
|
173
|
+
NODE_SHELF = fn.Shelf(
|
174
|
+
nodes=[
|
175
|
+
get_attribute,
|
176
|
+
has_attribute,
|
177
|
+
set_attribute,
|
178
|
+
delete_attribute,
|
179
|
+
],
|
180
|
+
name="Python Objects",
|
181
|
+
description="Access and transform general Python objects.",
|
182
|
+
subshelves=[],
|
183
|
+
)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: funcnodes-basic
|
3
|
-
Version: 0.
|
3
|
+
Version: 1.0.0
|
4
4
|
Summary: Basic functionalities for funcnodes
|
5
5
|
Author-email: Julian Kimmig <julian.kimmig@linkdlab.de>
|
6
6
|
License: AGPL-3.0
|
@@ -12,7 +12,7 @@ Classifier: License :: OSI Approved :: GNU Affero General Public License v3 or l
|
|
12
12
|
Requires-Python: >=3.11
|
13
13
|
Description-Content-Type: text/markdown
|
14
14
|
License-File: LICENSE
|
15
|
-
Requires-Dist: funcnodes-core>=0.
|
15
|
+
Requires-Dist: funcnodes-core>=1.0.5
|
16
16
|
Requires-Dist: funcnodes
|
17
17
|
Dynamic: license-file
|
18
18
|
|
@@ -1,14 +1,15 @@
|
|
1
|
-
funcnodes_basic/__init__.py,sha256=
|
1
|
+
funcnodes_basic/__init__.py,sha256=SIcd0uMAtX6o4OqcWwnbO4qnLO6b0HSdBR2UvLsYq64,738
|
2
2
|
funcnodes_basic/dataclass.py,sha256=p7IjTek7XnHOxZCJnFHhmNtmYM1DpacmfuaUePvDQ7Y,1732
|
3
3
|
funcnodes_basic/dicts.py,sha256=koNJEwIq9ryC7evBpnI-QmR7MBIbgUWqpPpwhB3M69Y,2507
|
4
4
|
funcnodes_basic/input.py,sha256=FSHS1bIJ2dJc9NqWaJO0MxegRBERhfxFdkmDiwAuE6o,1654
|
5
5
|
funcnodes_basic/lists.py,sha256=9kGnovK-oClFatslbIeYne27l2-EPEXZbr_6yQ1B1cY,5835
|
6
|
-
funcnodes_basic/logic.py,sha256=
|
6
|
+
funcnodes_basic/logic.py,sha256=HrJzM9h34PJUWiULU9Ol5iQ2tI6rl7c39iTt6RO6mRg,4952
|
7
7
|
funcnodes_basic/math_nodes.py,sha256=PasNf-1wAvbJ_c-_qeiIDaUVfgPQEREJApeUcTS4FQg,10586
|
8
|
+
funcnodes_basic/pyobjects.py,sha256=DHtMnbEkkpuhDEqrbdgW8UlaN9-WyfESkAbgwYaOFjM,5188
|
8
9
|
funcnodes_basic/strings.py,sha256=O6rcxBQJ5eYd765w_tolaD6xMwsNmtBjiPgJ_69tKyA,16429
|
9
|
-
funcnodes_basic-0.
|
10
|
-
funcnodes_basic-0.
|
11
|
-
funcnodes_basic-0.
|
12
|
-
funcnodes_basic-0.
|
13
|
-
funcnodes_basic-0.
|
14
|
-
funcnodes_basic-0.
|
10
|
+
funcnodes_basic-1.0.0.dist-info/licenses/LICENSE,sha256=21Lj2q2SYKHMY4768_a3pr3q0jY2VYamAHipoodhMDc,34273
|
11
|
+
funcnodes_basic-1.0.0.dist-info/METADATA,sha256=ksWmCMQjJ4OOeXrf_XJWlqo_ZX9iqDujZn8jFW850j4,2001
|
12
|
+
funcnodes_basic-1.0.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
13
|
+
funcnodes_basic-1.0.0.dist-info/entry_points.txt,sha256=HZ0g1oDO8PrL_f6b09lfTrS-jXqbZrP0qYf1Km_pVxw,79
|
14
|
+
funcnodes_basic-1.0.0.dist-info/top_level.txt,sha256=xYbcX5Jx-Ow3N3kgXtyvh8kuhCahb3eHBIZfMvkpVKI,16
|
15
|
+
funcnodes_basic-1.0.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|