py10x-universe 0.1.3__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.
- core_10x/__init__.py +42 -0
- core_10x/backbone/__init__.py +0 -0
- core_10x/backbone/backbone_store.py +59 -0
- core_10x/backbone/backbone_traitable.py +30 -0
- core_10x/backbone/backbone_user.py +66 -0
- core_10x/backbone/bound_data_domain.py +49 -0
- core_10x/backbone/namespace.py +101 -0
- core_10x/backbone/vault.py +38 -0
- core_10x/code_samples/__init__.py +0 -0
- core_10x/code_samples/_package_manifest.py +3 -0
- core_10x/code_samples/directories.py +181 -0
- core_10x/code_samples/person.py +76 -0
- core_10x/concrete_traits.py +356 -0
- core_10x/conftest.py +12 -0
- core_10x/curve.py +321 -0
- core_10x/data_domain.py +48 -0
- core_10x/data_domain_binder.py +45 -0
- core_10x/directory.py +250 -0
- core_10x/entity.py +8 -0
- core_10x/entity_filter.py +5 -0
- core_10x/environment_variables.py +147 -0
- core_10x/exec_control.py +84 -0
- core_10x/experimental/__init__.py +0 -0
- core_10x/experimental/data_protocol_ex.py +34 -0
- core_10x/global_cache.py +121 -0
- core_10x/manual_tests/__init__.py +0 -0
- core_10x/manual_tests/calendar_test.py +35 -0
- core_10x/manual_tests/ctor_update_bug.py +58 -0
- core_10x/manual_tests/debug_graph_on.py +17 -0
- core_10x/manual_tests/debug_graphoff_inside_graph_on.py +28 -0
- core_10x/manual_tests/enum_bits_test.py +17 -0
- core_10x/manual_tests/env_vars_trivial_test.py +12 -0
- core_10x/manual_tests/existing_traitable.py +33 -0
- core_10x/manual_tests/k10x_test1.py +13 -0
- core_10x/manual_tests/named_constant_test.py +121 -0
- core_10x/manual_tests/nucleus_trivial_test.py +42 -0
- core_10x/manual_tests/polars_test.py +14 -0
- core_10x/manual_tests/py_class_test.py +4 -0
- core_10x/manual_tests/rc_test.py +42 -0
- core_10x/manual_tests/rdate_test.py +12 -0
- core_10x/manual_tests/reference_serialization_bug.py +19 -0
- core_10x/manual_tests/resource_trivial_test.py +10 -0
- core_10x/manual_tests/store_uri_test.py +6 -0
- core_10x/manual_tests/trait_definition_test.py +19 -0
- core_10x/manual_tests/trait_filter_test.py +15 -0
- core_10x/manual_tests/trait_flag_modification_test.py +42 -0
- core_10x/manual_tests/trait_modification_bug.py +26 -0
- core_10x/manual_tests/traitable_as_of_test.py +82 -0
- core_10x/manual_tests/traitable_heir_test.py +39 -0
- core_10x/manual_tests/traitable_history_test.py +41 -0
- core_10x/manual_tests/traitable_serialization_test.py +54 -0
- core_10x/manual_tests/traitable_trivial_test.py +71 -0
- core_10x/manual_tests/trivial_graph_test.py +16 -0
- core_10x/manual_tests/ts_class_association_test.py +64 -0
- core_10x/manual_tests/ts_trivial_test.py +35 -0
- core_10x/named_constant.py +425 -0
- core_10x/nucleus.py +81 -0
- core_10x/package_manifest.py +85 -0
- core_10x/package_refactoring.py +153 -0
- core_10x/py_class.py +431 -0
- core_10x/rc.py +155 -0
- core_10x/rdate.py +339 -0
- core_10x/resource.py +189 -0
- core_10x/roman_number.py +67 -0
- core_10x/testlib/__init__.py +0 -0
- core_10x/testlib/test_store.py +240 -0
- core_10x/testlib/traitable_history_tests.py +787 -0
- core_10x/testlib/ts_tests.py +280 -0
- core_10x/trait.py +377 -0
- core_10x/trait_definition.py +176 -0
- core_10x/trait_filter.py +205 -0
- core_10x/trait_method_error.py +36 -0
- core_10x/traitable.py +1082 -0
- core_10x/traitable_cli.py +153 -0
- core_10x/traitable_heir.py +33 -0
- core_10x/traitable_id.py +31 -0
- core_10x/ts_store.py +172 -0
- core_10x/ts_store_type.py +26 -0
- core_10x/ts_union.py +147 -0
- core_10x/ui_hint.py +153 -0
- core_10x/unit_tests/test_concrete_traits.py +156 -0
- core_10x/unit_tests/test_converters.py +51 -0
- core_10x/unit_tests/test_curve.py +157 -0
- core_10x/unit_tests/test_directory.py +54 -0
- core_10x/unit_tests/test_documentation.py +172 -0
- core_10x/unit_tests/test_environment_variables.py +15 -0
- core_10x/unit_tests/test_filters.py +239 -0
- core_10x/unit_tests/test_graph.py +348 -0
- core_10x/unit_tests/test_named_constant.py +98 -0
- core_10x/unit_tests/test_rc.py +11 -0
- core_10x/unit_tests/test_rdate.py +484 -0
- core_10x/unit_tests/test_trait_method_error.py +80 -0
- core_10x/unit_tests/test_trait_modification.py +19 -0
- core_10x/unit_tests/test_traitable.py +959 -0
- core_10x/unit_tests/test_traitable_history.py +1 -0
- core_10x/unit_tests/test_ts_store.py +1 -0
- core_10x/unit_tests/test_ts_union.py +369 -0
- core_10x/unit_tests/test_ui_nodes.py +81 -0
- core_10x/unit_tests/test_xxcalendar.py +471 -0
- core_10x/vault/__init__.py +0 -0
- core_10x/vault/sec_keys.py +133 -0
- core_10x/vault/security_keys_old.py +168 -0
- core_10x/vault/vault.py +56 -0
- core_10x/vault/vault_traitable.py +56 -0
- core_10x/vault/vault_user.py +70 -0
- core_10x/xdate_time.py +136 -0
- core_10x/xnone.py +71 -0
- core_10x/xxcalendar.py +228 -0
- infra_10x/__init__.py +0 -0
- infra_10x/manual_tests/__init__.py +0 -0
- infra_10x/manual_tests/test_misc.py +16 -0
- infra_10x/manual_tests/test_prepare_filter_and_pipeline.py +25 -0
- infra_10x/mongodb_admin.py +111 -0
- infra_10x/mongodb_store.py +346 -0
- infra_10x/mongodb_utils.py +129 -0
- infra_10x/unit_tests/conftest.py +13 -0
- infra_10x/unit_tests/test_mongo_db.py +36 -0
- infra_10x/unit_tests/test_mongo_history.py +1 -0
- py10x_universe-0.1.3.dist-info/METADATA +406 -0
- py10x_universe-0.1.3.dist-info/RECORD +214 -0
- py10x_universe-0.1.3.dist-info/WHEEL +4 -0
- py10x_universe-0.1.3.dist-info/licenses/LICENSE +21 -0
- ui_10x/__init__.py +0 -0
- ui_10x/apps/__init__.py +0 -0
- ui_10x/apps/collection_editor_app.py +100 -0
- ui_10x/choice.py +212 -0
- ui_10x/collection_editor.py +135 -0
- ui_10x/concrete_trait_widgets.py +220 -0
- ui_10x/conftest.py +8 -0
- ui_10x/entity_stocker.py +173 -0
- ui_10x/examples/__init__.py +0 -0
- ui_10x/examples/_guess_word_data.py +14076 -0
- ui_10x/examples/collection_editor.py +17 -0
- ui_10x/examples/date_selector.py +14 -0
- ui_10x/examples/entity_stocker.py +18 -0
- ui_10x/examples/guess_word.py +392 -0
- ui_10x/examples/message_box.py +20 -0
- ui_10x/examples/multi_choice.py +17 -0
- ui_10x/examples/py_data_browser.py +66 -0
- ui_10x/examples/radiobox.py +29 -0
- ui_10x/examples/single_choice.py +31 -0
- ui_10x/examples/style_sheet.py +47 -0
- ui_10x/examples/trivial_entity_editor.py +18 -0
- ui_10x/platform.py +20 -0
- ui_10x/platform_interface.py +517 -0
- ui_10x/py_data_browser.py +249 -0
- ui_10x/qt6/__init__.py +0 -0
- ui_10x/qt6/conftest.py +8 -0
- ui_10x/qt6/manual_tests/__init__.py +0 -0
- ui_10x/qt6/manual_tests/basic_test.py +35 -0
- ui_10x/qt6/platform_implementation.py +275 -0
- ui_10x/qt6/utils.py +665 -0
- ui_10x/rio/__init__.py +0 -0
- ui_10x/rio/apps/examples/examples/__init__.py +22 -0
- ui_10x/rio/apps/examples/examples/components/__init__.py +3 -0
- ui_10x/rio/apps/examples/examples/components/collection_editor.py +15 -0
- ui_10x/rio/apps/examples/examples/pages/collection_editor.py +21 -0
- ui_10x/rio/apps/examples/examples/pages/login_page.py +88 -0
- ui_10x/rio/apps/examples/examples/pages/style_sheet.py +21 -0
- ui_10x/rio/apps/examples/rio.toml +14 -0
- ui_10x/rio/component_builder.py +497 -0
- ui_10x/rio/components/__init__.py +9 -0
- ui_10x/rio/components/group_box.py +31 -0
- ui_10x/rio/components/labeled_checkbox.py +18 -0
- ui_10x/rio/components/line_edit.py +37 -0
- ui_10x/rio/components/radio_button.py +32 -0
- ui_10x/rio/components/separator.py +24 -0
- ui_10x/rio/components/splitter.py +121 -0
- ui_10x/rio/components/tree_view.py +75 -0
- ui_10x/rio/conftest.py +35 -0
- ui_10x/rio/internals/__init__.py +0 -0
- ui_10x/rio/internals/app.py +192 -0
- ui_10x/rio/manual_tests/__init__.py +0 -0
- ui_10x/rio/manual_tests/basic_test.py +24 -0
- ui_10x/rio/manual_tests/splitter.py +27 -0
- ui_10x/rio/platform_implementation.py +91 -0
- ui_10x/rio/style_sheet.py +53 -0
- ui_10x/rio/unit_tests/test_collection_editor.py +68 -0
- ui_10x/rio/unit_tests/test_internals.py +630 -0
- ui_10x/rio/unit_tests/test_style_sheet.py +37 -0
- ui_10x/rio/widgets/__init__.py +46 -0
- ui_10x/rio/widgets/application.py +109 -0
- ui_10x/rio/widgets/button.py +48 -0
- ui_10x/rio/widgets/button_group.py +60 -0
- ui_10x/rio/widgets/calendar.py +23 -0
- ui_10x/rio/widgets/checkbox.py +24 -0
- ui_10x/rio/widgets/dialog.py +137 -0
- ui_10x/rio/widgets/group_box.py +27 -0
- ui_10x/rio/widgets/layout.py +34 -0
- ui_10x/rio/widgets/line_edit.py +37 -0
- ui_10x/rio/widgets/list.py +105 -0
- ui_10x/rio/widgets/message_box.py +70 -0
- ui_10x/rio/widgets/scroll_area.py +31 -0
- ui_10x/rio/widgets/spacer.py +6 -0
- ui_10x/rio/widgets/splitter.py +45 -0
- ui_10x/rio/widgets/text_edit.py +28 -0
- ui_10x/rio/widgets/tree.py +89 -0
- ui_10x/rio/widgets/unit_tests/test_button.py +101 -0
- ui_10x/rio/widgets/unit_tests/test_button_group.py +33 -0
- ui_10x/rio/widgets/unit_tests/test_calendar.py +114 -0
- ui_10x/rio/widgets/unit_tests/test_checkbox.py +109 -0
- ui_10x/rio/widgets/unit_tests/test_group_box.py +158 -0
- ui_10x/rio/widgets/unit_tests/test_label.py +43 -0
- ui_10x/rio/widgets/unit_tests/test_line_edit.py +140 -0
- ui_10x/rio/widgets/unit_tests/test_list.py +146 -0
- ui_10x/table_header_view.py +305 -0
- ui_10x/table_view.py +174 -0
- ui_10x/trait_editor.py +189 -0
- ui_10x/trait_widget.py +131 -0
- ui_10x/traitable_editor.py +200 -0
- ui_10x/traitable_view.py +131 -0
- ui_10x/unit_tests/conftest.py +8 -0
- ui_10x/unit_tests/test_platform.py +9 -0
- ui_10x/utils.py +661 -0
ui_10x/entity_stocker.py
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
from core_10x.traitable import RT, Traitable
|
|
4
|
+
|
|
5
|
+
from ui_10x.traitable_editor import TraitableEditor, TraitableView
|
|
6
|
+
from ui_10x.utils import ux, ux_answer, ux_push_button, ux_success, ux_warning
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class StockerPlug(Traitable):
|
|
10
|
+
master: Traitable
|
|
11
|
+
# fmt: off
|
|
12
|
+
current_class_trait_name: str = RT('current_class')
|
|
13
|
+
current_entity_trait_name: str = RT('current_entity')
|
|
14
|
+
changed_entity_cb_name: str = RT('on_changed_entity') #-- f(ce: Traitable) - after accepting edits and reloading
|
|
15
|
+
deleted_entity_cb_name: str = RT('on_deleted_entity') #-- f(de: Traitable)
|
|
16
|
+
# fmt: on
|
|
17
|
+
|
|
18
|
+
new_entity_cb: Any
|
|
19
|
+
changed_entity_cb: Any
|
|
20
|
+
deleted_entity_cb: Any
|
|
21
|
+
|
|
22
|
+
current_class: type
|
|
23
|
+
current_entity: Traitable
|
|
24
|
+
|
|
25
|
+
def _cb(self, cb_name: str):
|
|
26
|
+
m = self.master
|
|
27
|
+
if m:
|
|
28
|
+
cls = m.__class__
|
|
29
|
+
method = getattr(cls, cb_name, None)
|
|
30
|
+
if method:
|
|
31
|
+
return lambda e: method(m, e)
|
|
32
|
+
|
|
33
|
+
return lambda e: None
|
|
34
|
+
|
|
35
|
+
# fmt: off
|
|
36
|
+
def changed_entity_cb_get(self): return self._cb(self.changed_entity_cb_name)
|
|
37
|
+
def deleted_entity_cb_get(self): return self._cb(self.deleted_entity_cb_name)
|
|
38
|
+
# fmt: on
|
|
39
|
+
|
|
40
|
+
def current_class_get(self) -> type:
|
|
41
|
+
m = self.master
|
|
42
|
+
if not m:
|
|
43
|
+
return None
|
|
44
|
+
|
|
45
|
+
cls = m.get_value(self.current_class_trait_name)
|
|
46
|
+
if not cls:
|
|
47
|
+
ce = self.current_entity
|
|
48
|
+
if ce:
|
|
49
|
+
cls = ce.__class__
|
|
50
|
+
|
|
51
|
+
return cls
|
|
52
|
+
|
|
53
|
+
def current_entity_get(self) -> Traitable:
|
|
54
|
+
m = self.master
|
|
55
|
+
if not m:
|
|
56
|
+
return None
|
|
57
|
+
|
|
58
|
+
return m.get_value(self.current_entity_trait_name)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class EntityStocker(Traitable):
|
|
62
|
+
plug: StockerPlug
|
|
63
|
+
entity_viewer: TraitableEditor
|
|
64
|
+
buttons_spec: dict
|
|
65
|
+
|
|
66
|
+
def entity_viewer_get(self) -> TraitableEditor:
|
|
67
|
+
ce = self.plug.current_entity
|
|
68
|
+
if not ce:
|
|
69
|
+
return None
|
|
70
|
+
|
|
71
|
+
return TraitableEditor.editor(ce, view=TraitableView.default(ce.__class__, read_only=True))
|
|
72
|
+
|
|
73
|
+
def top_layout(self) -> ux.HBoxLayout:
|
|
74
|
+
lay = ux.HBoxLayout()
|
|
75
|
+
lay.set_spacing(0)
|
|
76
|
+
|
|
77
|
+
for name, (cb, icon) in self.buttons_spec.items():
|
|
78
|
+
lay.add_widget(ux_push_button(name, callback=cb, style_icon=icon))
|
|
79
|
+
|
|
80
|
+
return lay
|
|
81
|
+
|
|
82
|
+
def main_widget(self) -> ux.Widget:
|
|
83
|
+
entity_viewer = self.entity_viewer
|
|
84
|
+
if entity_viewer:
|
|
85
|
+
lay = ux.VBoxLayout()
|
|
86
|
+
lay.add_layout(self.top_layout(), stretch=0)
|
|
87
|
+
lay.add_widget(entity_viewer.main_widget())
|
|
88
|
+
|
|
89
|
+
else:
|
|
90
|
+
lay = self.top_layout()
|
|
91
|
+
|
|
92
|
+
w = ux.Widget()
|
|
93
|
+
w.set_layout(lay)
|
|
94
|
+
return w
|
|
95
|
+
|
|
96
|
+
# def on_new_entity(self):
|
|
97
|
+
# cls = self.plug.current_class
|
|
98
|
+
# if cls:
|
|
99
|
+
# new_entity = cls()
|
|
100
|
+
# ed = TraitableEditor.editor(new_entity)
|
|
101
|
+
# if ed.popup(copy_entity = False, title = f'New Entity of {cls.__name__}', save = True):
|
|
102
|
+
# rc = new_entity.share(False) #-- not accepting existing entity values, if any
|
|
103
|
+
# if not rc:
|
|
104
|
+
# ux_warning(rc.error(), parent = None) #-- TODO: parent must be an existing appropriate widget
|
|
105
|
+
# #-- TODO: what to do with a temp new_entity?
|
|
106
|
+
#
|
|
107
|
+
# else:
|
|
108
|
+
# self.plug.new_entity_cb(new_entity)
|
|
109
|
+
|
|
110
|
+
def on_edit_entity(self):
|
|
111
|
+
ce = self.plug.current_entity
|
|
112
|
+
if ce:
|
|
113
|
+
ed = TraitableEditor.editor(ce)
|
|
114
|
+
if ed.popup():
|
|
115
|
+
self.plug.changed_entity_cb(ce)
|
|
116
|
+
|
|
117
|
+
def on_reload_entity(self):
|
|
118
|
+
ce = self.plug.current_entity
|
|
119
|
+
if ce:
|
|
120
|
+
if not ce.reload():
|
|
121
|
+
ux_warning(f'Failed to reload entity {ce.__class__}/{ce.id()}', parent=None, on_close=lambda ctx: None)
|
|
122
|
+
else:
|
|
123
|
+
self.plug.changed_entity_cb(ce)
|
|
124
|
+
|
|
125
|
+
def on_save_entity(self):
|
|
126
|
+
ce = self.plug.current_entity
|
|
127
|
+
if ce:
|
|
128
|
+
try:
|
|
129
|
+
rc = ce.save()
|
|
130
|
+
if not rc:
|
|
131
|
+
ux_warning(rc.error(), parent=None, on_close=lambda ctx: None)
|
|
132
|
+
|
|
133
|
+
return
|
|
134
|
+
|
|
135
|
+
except Exception: # -- revision conflict?
|
|
136
|
+
# -- TODO: resolve revision conflict - MergingEditor
|
|
137
|
+
...
|
|
138
|
+
|
|
139
|
+
# -- The conflict seems to be resolved, try again
|
|
140
|
+
try:
|
|
141
|
+
rc = ce.save()
|
|
142
|
+
if not rc:
|
|
143
|
+
ux_warning(rc.error(), parent=None, on_close=lambda ctx: None)
|
|
144
|
+
return
|
|
145
|
+
|
|
146
|
+
except Exception:
|
|
147
|
+
ux_warning('Failed to resolve revision conflict (most probably due to continuous updates from other session(s)')
|
|
148
|
+
return
|
|
149
|
+
|
|
150
|
+
ux_success(f'Conflict resolved, {ce.__class__}/{ce.id()} has been saved', on_close=lambda ctx: None)
|
|
151
|
+
|
|
152
|
+
def on_delete_entity(self):
|
|
153
|
+
ce = self.plug.current_entity
|
|
154
|
+
if ce:
|
|
155
|
+
|
|
156
|
+
def on_close(accepted: bool):
|
|
157
|
+
if accepted:
|
|
158
|
+
if not ce.delete():
|
|
159
|
+
ux_warning('Deletion failed: {ce.__class__}/{ce.id()', parent=None, on_close=lambda ctx: None)
|
|
160
|
+
self.plug.deleted_entity_cb(ce)
|
|
161
|
+
|
|
162
|
+
ux_answer(f'Please confirm deletion of {ce.__class__}/{ce.id()}', parent=None, on_close=on_close)
|
|
163
|
+
|
|
164
|
+
def buttons_spec_get(self) -> dict:
|
|
165
|
+
# fmt: off
|
|
166
|
+
return dict(
|
|
167
|
+
#new = (self.on_new_entity, 'FileIcon'),
|
|
168
|
+
edit = (self.on_edit_entity, 'FileDialogDetailedView'),
|
|
169
|
+
reload = (self.on_reload_entity, 'ArrowDown'),
|
|
170
|
+
save = (self.on_save_entity, 'DriveNetIcon'),
|
|
171
|
+
delete = (self.on_delete_entity, 'DialogDiscardButton')
|
|
172
|
+
)
|
|
173
|
+
# fmt: on
|
|
File without changes
|