xstack 2.0.2__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.
- xstack/__init__.py +167 -0
- xstack/address.py +137 -0
- xstack/app/__init__.py +36 -0
- xstack/app/__main__.py +5 -0
- xstack/app/application.py +692 -0
- xstack/app/config.py +139 -0
- xstack/app/delegate.py +292 -0
- xstack/app/demo.py +42 -0
- xstack/app/dialogs.py +492 -0
- xstack/app/log_view.py +632 -0
- xstack/app/menu.py +362 -0
- xstack/app/options.py +664 -0
- xstack/app/resources.py +20 -0
- xstack/app/runner.py +35 -0
- xstack/app/settings.py +89 -0
- xstack/app/tree.py +582 -0
- xstack/attributes.py +212 -0
- xstack/compat.py +96 -0
- xstack/component.py +1175 -0
- xstack/constants.py +16 -0
- xstack/stack.py +1078 -0
- xstack/test/__init__.py +0 -0
- xstack/test/components.py +360 -0
- xstack/test/test_stack.py +1314 -0
- xstack-2.0.2.dist-info/METADATA +162 -0
- xstack-2.0.2.dist-info/RECORD +29 -0
- xstack-2.0.2.dist-info/WHEEL +5 -0
- xstack-2.0.2.dist-info/licenses/LICENSE +21 -0
- xstack-2.0.2.dist-info/top_level.txt +1 -0
xstack/test/__init__.py
ADDED
|
File without changes
|
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
import xstack
|
|
2
|
+
|
|
3
|
+
class MinimalComponent(xstack.Component):
|
|
4
|
+
"""
|
|
5
|
+
The most basic style of component. No options, no requirements.
|
|
6
|
+
"""
|
|
7
|
+
identifier = "MinimalComponent"
|
|
8
|
+
|
|
9
|
+
def __init__(self, *args, **kwargs):
|
|
10
|
+
super().__init__(*args, **kwargs)
|
|
11
|
+
|
|
12
|
+
def run(self):
|
|
13
|
+
return True
|
|
14
|
+
|
|
15
|
+
class VersionedComponent1(xstack.Component):
|
|
16
|
+
"""
|
|
17
|
+
The most basic style of component. No options, no requirements.
|
|
18
|
+
"""
|
|
19
|
+
identifier = "Versioned Component"
|
|
20
|
+
version = 1
|
|
21
|
+
|
|
22
|
+
def __init__(self, *args, **kwargs):
|
|
23
|
+
super().__init__(*args, **kwargs)
|
|
24
|
+
|
|
25
|
+
def run(self):
|
|
26
|
+
return True
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class VersionedComponent2(xstack.Component):
|
|
30
|
+
"""
|
|
31
|
+
The most basic style of component. No options, no requirements.
|
|
32
|
+
"""
|
|
33
|
+
identifier = "Versioned Component"
|
|
34
|
+
version = 2
|
|
35
|
+
|
|
36
|
+
def __init__(self, *args, **kwargs):
|
|
37
|
+
super().__init__(*args, **kwargs)
|
|
38
|
+
|
|
39
|
+
def run(self):
|
|
40
|
+
return True
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class VersionedComponent3(xstack.Component):
|
|
44
|
+
"""
|
|
45
|
+
The most basic style of component. No options, no requirements.
|
|
46
|
+
"""
|
|
47
|
+
identifier = "Versioned Component"
|
|
48
|
+
version = 3
|
|
49
|
+
|
|
50
|
+
def __init__(self, *args, **kwargs):
|
|
51
|
+
super().__init__(*args, **kwargs)
|
|
52
|
+
|
|
53
|
+
def run(self):
|
|
54
|
+
return True
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class FailingComponent(xstack.Component):
|
|
58
|
+
"""
|
|
59
|
+
This component is designed to fail during a build
|
|
60
|
+
"""
|
|
61
|
+
|
|
62
|
+
identifier = "FailingComponent"
|
|
63
|
+
|
|
64
|
+
def __init__(self, *args, **kwargs):
|
|
65
|
+
super().__init__(*args, **kwargs)
|
|
66
|
+
|
|
67
|
+
def run(self):
|
|
68
|
+
raise Exception("Enforced Failure")
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
class ComponentWithExpectedRequirementSet(xstack.Component):
|
|
72
|
+
"""
|
|
73
|
+
This has one expected requirement
|
|
74
|
+
"""
|
|
75
|
+
identifier = "ComponentWithExpectedRequirementSet"
|
|
76
|
+
|
|
77
|
+
def __init__(self, *args, **kwargs):
|
|
78
|
+
super().__init__(*args, **kwargs)
|
|
79
|
+
|
|
80
|
+
self.declare_input(
|
|
81
|
+
name="expected_requirement",
|
|
82
|
+
value=1,
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
class ComponentWithExpectedRequirementNotSet(xstack.Component):
|
|
86
|
+
identifier = "ComponentWithExpectedRequirementNotSet"
|
|
87
|
+
|
|
88
|
+
def __init__(self, *args, **kwargs):
|
|
89
|
+
super().__init__(*args, **kwargs)
|
|
90
|
+
|
|
91
|
+
self.declare_input(
|
|
92
|
+
name="expected_requirement",
|
|
93
|
+
value="",
|
|
94
|
+
validate=True,
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
class ComponentWithOption(xstack.Component):
|
|
99
|
+
identifier = "ComponentWithOption"
|
|
100
|
+
|
|
101
|
+
def __init__(self, *args, **kwargs):
|
|
102
|
+
super().__init__(*args, **kwargs)
|
|
103
|
+
|
|
104
|
+
self.declare_option(
|
|
105
|
+
name="test_option",
|
|
106
|
+
value="foo",
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
def run(self):
|
|
110
|
+
return self.option("test_option").get() == "bar"
|
|
111
|
+
|
|
112
|
+
class ComponentWithPreExposeOption(xstack.Component):
|
|
113
|
+
identifier = "ComponentWithPreExposeOption"
|
|
114
|
+
|
|
115
|
+
def __init__(self, *args, **kwargs):
|
|
116
|
+
super().__init__(*args, **kwargs)
|
|
117
|
+
|
|
118
|
+
self.declare_option(
|
|
119
|
+
name="test_option",
|
|
120
|
+
value="foo",
|
|
121
|
+
pre_expose=True,
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
def suggested_label(self):
|
|
125
|
+
return self.identifier + " : " + self.option("test_option").get()
|
|
126
|
+
def run(self):
|
|
127
|
+
return self.option("test_option").get() == "bar"
|
|
128
|
+
|
|
129
|
+
class InvalidComponent(xstack.Component):
|
|
130
|
+
identifier = "InvalidComponent"
|
|
131
|
+
|
|
132
|
+
def is_valid(self) -> bool:
|
|
133
|
+
return False
|
|
134
|
+
|
|
135
|
+
class RunTestComponent(xstack.Component):
|
|
136
|
+
|
|
137
|
+
identifier = "RunTestComponent"
|
|
138
|
+
|
|
139
|
+
RUN_ORDER = []
|
|
140
|
+
|
|
141
|
+
def run(self) -> bool:
|
|
142
|
+
RunTestComponent.RUN_ORDER.append(self)
|
|
143
|
+
|
|
144
|
+
return True
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
class ComponentWithTenOptions(xstack.Component):
|
|
148
|
+
|
|
149
|
+
identifier = "ComponentWithTenOptions"
|
|
150
|
+
|
|
151
|
+
RUN_ORDER = []
|
|
152
|
+
|
|
153
|
+
def __init__(self, *args, **kwargs):
|
|
154
|
+
super().__init__(*args, **kwargs)
|
|
155
|
+
|
|
156
|
+
for i in range(10):
|
|
157
|
+
self.declare_option(
|
|
158
|
+
name=f"test_option{i}",
|
|
159
|
+
value="foo",
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
def run(self) -> bool:
|
|
163
|
+
RunTestComponent.RUN_ORDER.append(self)
|
|
164
|
+
|
|
165
|
+
return True
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
class ComponentWithOutputs(xstack.Component):
|
|
169
|
+
|
|
170
|
+
identifier = "ComponentWithOutputs"
|
|
171
|
+
|
|
172
|
+
RUN_ORDER = []
|
|
173
|
+
|
|
174
|
+
def __init__(self, *args, **kwargs):
|
|
175
|
+
super().__init__(*args, **kwargs)
|
|
176
|
+
|
|
177
|
+
for i in range(3):
|
|
178
|
+
self.declare_output(
|
|
179
|
+
name=f"test_output{i}",
|
|
180
|
+
)
|
|
181
|
+
|
|
182
|
+
def run(self) -> bool:
|
|
183
|
+
RunTestComponent.RUN_ORDER.append(self)
|
|
184
|
+
|
|
185
|
+
self.output("test_output0").set("A")
|
|
186
|
+
self.output("test_output1").set("B")
|
|
187
|
+
self.output("test_output2").set("C")
|
|
188
|
+
return True
|
|
189
|
+
|
|
190
|
+
class ParentHookingComponent(xstack.Component):
|
|
191
|
+
"""
|
|
192
|
+
Records the parent it has when it enters the stack, and hooks its
|
|
193
|
+
"Parent" input to its parent's default output - as many real components
|
|
194
|
+
do in on_enter_stack.
|
|
195
|
+
"""
|
|
196
|
+
identifier = "ParentHookingComponent"
|
|
197
|
+
|
|
198
|
+
def __init__(self, *args, **kwargs):
|
|
199
|
+
super().__init__(*args, **kwargs)
|
|
200
|
+
|
|
201
|
+
self.parent_on_enter = None
|
|
202
|
+
|
|
203
|
+
self.declare_input(name="Parent", value="")
|
|
204
|
+
self.declare_output(name="Control", is_default=True)
|
|
205
|
+
|
|
206
|
+
def on_enter_stack(self):
|
|
207
|
+
self.parent_on_enter = self.parent
|
|
208
|
+
self.input("Parent").hook_to_parent()
|
|
209
|
+
|
|
210
|
+
def run(self):
|
|
211
|
+
return True
|
|
212
|
+
|
|
213
|
+
class AdditionalDataComponent(xstack.Component):
|
|
214
|
+
"""
|
|
215
|
+
Stores its "payload" attribute as additional data, and records what it was
|
|
216
|
+
given back when deserialised.
|
|
217
|
+
"""
|
|
218
|
+
identifier = "AdditionalDataComponent"
|
|
219
|
+
|
|
220
|
+
def __init__(self, *args, **kwargs):
|
|
221
|
+
super().__init__(*args, **kwargs)
|
|
222
|
+
self.payload = dict()
|
|
223
|
+
self.received = None
|
|
224
|
+
|
|
225
|
+
def on_serialise(self):
|
|
226
|
+
return dict(self.payload)
|
|
227
|
+
|
|
228
|
+
def on_deserialise(self, additional_data):
|
|
229
|
+
self.received = additional_data
|
|
230
|
+
|
|
231
|
+
def run(self):
|
|
232
|
+
return True
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
class ReturnsFalseComponent(xstack.Component):
|
|
236
|
+
"""
|
|
237
|
+
Reports failure by returning False from run
|
|
238
|
+
"""
|
|
239
|
+
identifier = "ReturnsFalseComponent"
|
|
240
|
+
|
|
241
|
+
def run(self):
|
|
242
|
+
return False
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
class NestedBuildComponent(xstack.Component):
|
|
246
|
+
"""
|
|
247
|
+
Builds the components below the component labelled by its "Target" option
|
|
248
|
+
"""
|
|
249
|
+
identifier = "NestedBuildComponent"
|
|
250
|
+
|
|
251
|
+
def __init__(self, *args, **kwargs):
|
|
252
|
+
super().__init__(*args, **kwargs)
|
|
253
|
+
|
|
254
|
+
self.declare_option(name="Target", value="")
|
|
255
|
+
|
|
256
|
+
def run(self):
|
|
257
|
+
target = self.stack.get_component_by_label(self.option("Target").get())
|
|
258
|
+
return self.stack.build(build_below=target)
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
class MigratingComponent(xstack.Component):
|
|
262
|
+
"""
|
|
263
|
+
Version 2 renamed its "Old Name" option to "New Name"
|
|
264
|
+
"""
|
|
265
|
+
identifier = "MigratingComponent"
|
|
266
|
+
version = 2
|
|
267
|
+
|
|
268
|
+
def __init__(self, *args, **kwargs):
|
|
269
|
+
super().__init__(*args, **kwargs)
|
|
270
|
+
|
|
271
|
+
self.declare_option(name="New Name", value="")
|
|
272
|
+
|
|
273
|
+
@classmethod
|
|
274
|
+
def migrate(cls, data, from_version):
|
|
275
|
+
options = data.get("options", dict())
|
|
276
|
+
|
|
277
|
+
if from_version < 2 and "Old Name" in options:
|
|
278
|
+
options["New Name"] = options.pop("Old Name")
|
|
279
|
+
|
|
280
|
+
return data
|
|
281
|
+
|
|
282
|
+
def run(self):
|
|
283
|
+
return True
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
class FailingAdditionalDataComponent(xstack.Component):
|
|
287
|
+
"""
|
|
288
|
+
Raises from both additional data hooks.
|
|
289
|
+
"""
|
|
290
|
+
identifier = "FailingAdditionalDataComponent"
|
|
291
|
+
|
|
292
|
+
def on_serialise(self):
|
|
293
|
+
raise RuntimeError("on_serialise failure")
|
|
294
|
+
|
|
295
|
+
def on_deserialise(self, additional_data):
|
|
296
|
+
raise RuntimeError("on_deserialise failure")
|
|
297
|
+
|
|
298
|
+
def run(self):
|
|
299
|
+
return True
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
class RenamedComponent(xstack.Component):
|
|
303
|
+
"""
|
|
304
|
+
Was previously called "Old Renamed Component" (and before that "Older
|
|
305
|
+
Renamed Component"). It also lists MinimalComponent, which is a live
|
|
306
|
+
identifier, so must never be resolved to this component.
|
|
307
|
+
"""
|
|
308
|
+
identifier = "RenamedComponent"
|
|
309
|
+
deprecated_names = ["Old Renamed Component", "Older Renamed Component", "MinimalComponent"]
|
|
310
|
+
|
|
311
|
+
def __init__(self, *args, **kwargs):
|
|
312
|
+
super().__init__(*args, **kwargs)
|
|
313
|
+
|
|
314
|
+
self.declare_option(name="test_option", value="")
|
|
315
|
+
|
|
316
|
+
def run(self):
|
|
317
|
+
return True
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
class RenamedMigratingComponent(xstack.Component):
|
|
321
|
+
"""
|
|
322
|
+
Was previously called "Old Migrating Name", and version 2 renamed its
|
|
323
|
+
"Old Option" option to "New Option". It records the component type
|
|
324
|
+
migrate was given.
|
|
325
|
+
"""
|
|
326
|
+
identifier = "RenamedMigratingComponent"
|
|
327
|
+
deprecated_names = ["Old Migrating Name"]
|
|
328
|
+
version = 2
|
|
329
|
+
|
|
330
|
+
migrated_component_types = []
|
|
331
|
+
|
|
332
|
+
def __init__(self, *args, **kwargs):
|
|
333
|
+
super().__init__(*args, **kwargs)
|
|
334
|
+
|
|
335
|
+
self.declare_option(name="New Option", value="")
|
|
336
|
+
|
|
337
|
+
@classmethod
|
|
338
|
+
def migrate(cls, data, from_version):
|
|
339
|
+
cls.migrated_component_types.append(data["component_type"])
|
|
340
|
+
options = data.get("options", dict())
|
|
341
|
+
|
|
342
|
+
if from_version < 2 and "Old Option" in options:
|
|
343
|
+
options["New Option"] = options.pop("Old Option")
|
|
344
|
+
|
|
345
|
+
return data
|
|
346
|
+
|
|
347
|
+
def run(self):
|
|
348
|
+
return True
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
class BareStringDeprecatedNameComponent(xstack.Component):
|
|
352
|
+
"""
|
|
353
|
+
Wrongly gives deprecated_names as a string rather than a list, so it must
|
|
354
|
+
not be searched character by character.
|
|
355
|
+
"""
|
|
356
|
+
identifier = "BareStringDeprecatedNameComponent"
|
|
357
|
+
deprecated_names = "Bare Old Name"
|
|
358
|
+
|
|
359
|
+
def run(self):
|
|
360
|
+
return True
|