bnop 0.2.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.
Files changed (50) hide show
  1. bnop/__init__.py +0 -0
  2. bnop/bnop_facades.py +307 -0
  3. bnop/bnop_io/__init__.py +0 -0
  4. bnop/bnop_io/shelve_bnop.py +42 -0
  5. bnop/core/__init__.py +0 -0
  6. bnop/core/factories/__init__.py +0 -0
  7. bnop/core/factories/bnop_element_factories.py +16 -0
  8. bnop/core/factories/bnop_name_factories.py +22 -0
  9. bnop/core/factories/bnop_object_factories.py +29 -0
  10. bnop/core/factories/bnop_placeabletype_factories.py +22 -0
  11. bnop/core/factories/bnop_tuple_factories.py +25 -0
  12. bnop/core/factories/bnop_type_factories.py +26 -0
  13. bnop/core/factories/bnop_type_place_factories.py +26 -0
  14. bnop/core/object_model/__init__.py +0 -0
  15. bnop/core/object_model/bnop_repositories.py +4 -0
  16. bnop/core/object_model/objects/__init__.py +0 -0
  17. bnop/core/object_model/objects/bnop_elements.py +26 -0
  18. bnop/core/object_model/objects/bnop_names.py +29 -0
  19. bnop/core/object_model/objects/bnop_objects.py +86 -0
  20. bnop/core/object_model/objects/bnop_placeable_types.py +32 -0
  21. bnop/core/object_model/objects/bnop_representations.py +24 -0
  22. bnop/core/object_model/objects/bnop_tuples.py +33 -0
  23. bnop/core/object_model/objects/bnop_type_places.py +34 -0
  24. bnop/core/object_model/objects/bnop_types.py +7 -0
  25. bnop/core/object_model/objects/places/__init__.py +0 -0
  26. bnop/core/object_model/objects/places/bnop_placed_objects_dictionaries.py +35 -0
  27. bnop/core/object_model/objects/places/bnop_placed_types_dictionaries.py +35 -0
  28. bnop/infrastructure/__init__.py +0 -0
  29. bnop/infrastructure/names.py +55 -0
  30. bnop/infrastructure/translators.py +33 -0
  31. bnop/mappings/__init__.py +0 -0
  32. bnop/mappings/boro_object_ckid_mappings.py +54 -0
  33. bnop/migrations/__init__.py +0 -0
  34. bnop/migrations/bnop_to_xml_migration/__init__.py +0 -0
  35. bnop/migrations/bnop_to_xml_migration/adders/__init__.py +0 -0
  36. bnop/migrations/bnop_to_xml_migration/adders/bnop_name_xml_adder.py +89 -0
  37. bnop/migrations/bnop_to_xml_migration/adders/bnop_object_xml_adder.py +120 -0
  38. bnop/migrations/bnop_to_xml_migration/adders/bnop_xml_named_objects_adder.py +42 -0
  39. bnop/migrations/bnop_to_xml_migration/adders/bnop_xml_names_adder.py +36 -0
  40. bnop/migrations/bnop_to_xml_migration/bnop_xml_write_orchestrator.py +42 -0
  41. bnop/migrations/bnop_to_xml_migration/common_knowledge/__init__.py +0 -0
  42. bnop/migrations/bnop_to_xml_migration/common_knowledge/bnop_to_xml_migration_configurations.py +6 -0
  43. bnop/migrations/bnop_to_xml_migration/common_knowledge/vanilla_bnop_to_xml_migration_configurations.py +27 -0
  44. bnop/migrations/bnop_to_xml_migration/sorters/__init__.py +0 -0
  45. bnop/migrations/bnop_to_xml_migration/sorters/bnop_name_sorters.py +31 -0
  46. bnop/migrations/bnop_to_xml_migration/xml_bnop_registers.py +133 -0
  47. bnop-0.2.0.dist-info/LICENSE.md +21 -0
  48. bnop-0.2.0.dist-info/METADATA +61 -0
  49. bnop-0.2.0.dist-info/RECORD +50 -0
  50. bnop-0.2.0.dist-info/WHEEL +4 -0
bnop/__init__.py ADDED
File without changes
bnop/bnop_facades.py ADDED
@@ -0,0 +1,307 @@
1
+ from bclearer_core.ckids.boro_object_ckids import (
2
+ BoroObjectCkIds,
3
+ )
4
+ from bclearer_core.ckids.place_number_type_ckids import (
5
+ PlaceNumberTypeCkIds,
6
+ )
7
+ from bclearer_orchestration_services.identification_services.uuid_service.uuid_helpers.uuid_factory import (
8
+ create_new_uuid,
9
+ )
10
+ from bnop.core.factories.bnop_element_factories import (
11
+ BnopElementFactories,
12
+ )
13
+ from bnop.core.factories.bnop_name_factories import (
14
+ BnopNameFactories,
15
+ )
16
+ from bnop.core.factories.bnop_object_factories import (
17
+ BnopObjectFactories,
18
+ )
19
+ from bnop.core.factories.bnop_placeabletype_factories import (
20
+ BnopPlaceableTypeFactories,
21
+ )
22
+ from bnop.core.factories.bnop_tuple_factories import (
23
+ BnopTupleFactories,
24
+ )
25
+ from bnop.core.factories.bnop_type_factories import (
26
+ BnopTypeFactories,
27
+ )
28
+ from bnop.core.factories.bnop_type_place_factories import (
29
+ BnopTypePlaceFactories,
30
+ )
31
+ from bnop.core.object_model.objects.bnop_names import (
32
+ BnopNames,
33
+ )
34
+ from bnop.core.object_model.objects.bnop_objects import (
35
+ BnopObjects,
36
+ )
37
+ from bnop.core.object_model.objects.places.bnop_placed_objects_dictionaries import (
38
+ BnopPlacedObjectsDictionaries,
39
+ )
40
+ from bnop.core.object_model.objects.places.bnop_placed_types_dictionaries import (
41
+ BnopPlacedTypesDictionaries,
42
+ )
43
+ from bnop.migrations.bnop_to_xml_migration.bnop_xml_write_orchestrator import (
44
+ orchestrate_xml_write,
45
+ )
46
+
47
+
48
+ class BnopFacades:
49
+
50
+ @staticmethod
51
+ def write_bnop_object_to_xml(
52
+ xml_file_path: str,
53
+ ):
54
+ orchestrate_xml_write(
55
+ xml_file_path=xml_file_path
56
+ )
57
+
58
+ @staticmethod
59
+ def create_new_bnop_type(
60
+ owning_repository_uuid,
61
+ ):
62
+ bnop_type = (
63
+ BnopTypeFactories.create(
64
+ create_new_uuid(),
65
+ owning_repository_uuid,
66
+ )
67
+ )
68
+
69
+ return bnop_type
70
+
71
+ @staticmethod
72
+ def create_bnop_object(
73
+ object_uuid,
74
+ owning_repository_uuid,
75
+ presentation_name=str(),
76
+ ):
77
+ bnop_object = BnopObjectFactories.create(
78
+ object_uuid,
79
+ owning_repository_uuid,
80
+ presentation_name=presentation_name,
81
+ )
82
+
83
+ return bnop_object
84
+
85
+ @staticmethod
86
+ def create_bnop_type(
87
+ type_uuid,
88
+ owning_repository_uuid,
89
+ presentation_name=str(),
90
+ ):
91
+ bnop_type = BnopTypeFactories.create(
92
+ type_uuid,
93
+ owning_repository_uuid,
94
+ presentation_name=presentation_name,
95
+ )
96
+
97
+ return bnop_type
98
+
99
+ @staticmethod
100
+ def create_new_bnop_element(
101
+ owning_repository_uuid,
102
+ ):
103
+ bnop_element = (
104
+ BnopElementFactories.create(
105
+ create_new_uuid(),
106
+ owning_repository_uuid,
107
+ )
108
+ )
109
+
110
+ return bnop_element
111
+
112
+ @staticmethod
113
+ def create_bnop_element(
114
+ element_uuid,
115
+ owning_repository_uuid,
116
+ ):
117
+ bnop_element = (
118
+ BnopElementFactories.create(
119
+ element_uuid,
120
+ owning_repository_uuid,
121
+ )
122
+ )
123
+
124
+ return bnop_element
125
+
126
+ @staticmethod
127
+ def create_new_bnop_name(
128
+ exemplar_representation,
129
+ owning_repository_uuid,
130
+ ):
131
+ bnop_name = (
132
+ BnopNameFactories.create(
133
+ create_new_uuid(),
134
+ exemplar_representation,
135
+ owning_repository_uuid,
136
+ )
137
+ )
138
+
139
+ return bnop_name
140
+
141
+ @staticmethod
142
+ def create_bnop_name(
143
+ name_uuid,
144
+ exemplar_representation,
145
+ owning_repository_uuid,
146
+ presentation_name=str(),
147
+ ):
148
+ bnop_name = BnopNameFactories.create(
149
+ name_uuid,
150
+ exemplar_representation,
151
+ owning_repository_uuid,
152
+ presentation_name=presentation_name,
153
+ )
154
+
155
+ return bnop_name
156
+
157
+ @staticmethod
158
+ def create_new_bnop_tuple_from_two_placed_objects(
159
+ placed1_object,
160
+ placed2_object,
161
+ immutable_minor_composition_couple_type_boro_object_ckid,
162
+ owning_repository_uuid,
163
+ ):
164
+ tuple_placed_objects_dictionary = (
165
+ BnopPlacedObjectsDictionaries()
166
+ )
167
+
168
+ tuple_placed_objects_dictionary.add_tuple_placed_object_to_dictionary(
169
+ PlaceNumberTypeCkIds.PlaceNumberOnes,
170
+ placed1_object,
171
+ )
172
+
173
+ tuple_placed_objects_dictionary.add_tuple_placed_object_to_dictionary(
174
+ PlaceNumberTypeCkIds.PlaceNumberTwos,
175
+ placed2_object,
176
+ )
177
+
178
+ bnop_tuple = BnopTupleFactories.create(
179
+ create_new_uuid(),
180
+ tuple_placed_objects_dictionary,
181
+ immutable_minor_composition_couple_type_boro_object_ckid,
182
+ owning_repository_uuid,
183
+ )
184
+
185
+ return bnop_tuple
186
+
187
+ @staticmethod
188
+ def create_bnop_tuple_from_two_placed_objects(
189
+ tuple_uuid,
190
+ placed1_object: BnopObjects,
191
+ placed2_object: BnopObjects,
192
+ immutable_minor_composition_couple_type_boro_object_ckid: BoroObjectCkIds,
193
+ owning_repository_uuid,
194
+ ):
195
+ tuple_placed_objects_dictionary = (
196
+ BnopPlacedObjectsDictionaries()
197
+ )
198
+
199
+ tuple_placed_objects_dictionary.add_tuple_placed_object_to_dictionary(
200
+ PlaceNumberTypeCkIds.PlaceNumberOnes,
201
+ placed1_object,
202
+ )
203
+
204
+ tuple_placed_objects_dictionary.add_tuple_placed_object_to_dictionary(
205
+ PlaceNumberTypeCkIds.PlaceNumberTwos,
206
+ placed2_object,
207
+ )
208
+
209
+ bnop_tuple = BnopTupleFactories.create(
210
+ tuple_uuid,
211
+ tuple_placed_objects_dictionary,
212
+ immutable_minor_composition_couple_type_boro_object_ckid,
213
+ owning_repository_uuid,
214
+ )
215
+
216
+ if (
217
+ immutable_minor_composition_couple_type_boro_object_ckid
218
+ == BoroObjectCkIds.SuperSubTypes
219
+ ):
220
+ placed2_object.supertypes.add(
221
+ placed1_object
222
+ )
223
+
224
+ placed1_object.subtypes.add(
225
+ placed2_object
226
+ )
227
+
228
+ if (
229
+ immutable_minor_composition_couple_type_boro_object_ckid
230
+ == BoroObjectCkIds.NamedBy
231
+ ):
232
+ placed1_object.is_named_bys.add(
233
+ placed2_object
234
+ )
235
+
236
+ placed2_object.names.add(
237
+ placed1_object
238
+ )
239
+
240
+ if (
241
+ immutable_minor_composition_couple_type_boro_object_ckid
242
+ == BoroObjectCkIds.TypesInstances
243
+ ):
244
+ placed2_object.types.add(
245
+ placed1_object
246
+ )
247
+
248
+ placed1_object.instances.add(
249
+ placed2_object
250
+ )
251
+
252
+ if (
253
+ type(placed2_object)
254
+ is BnopNames
255
+ ):
256
+ placed2_object.naming_spaces.add(
257
+ placed1_object
258
+ )
259
+
260
+ return bnop_tuple
261
+
262
+ @staticmethod
263
+ def create_bnop_placeabletype(
264
+ placeabletype_uuid,
265
+ owning_repository_uuid,
266
+ presentation_name=str(),
267
+ ):
268
+ placeable_type_placed_type_dictionary = (
269
+ BnopPlacedTypesDictionaries()
270
+ )
271
+
272
+ bnop_placeabletype = BnopPlaceableTypeFactories.create(
273
+ placeabletype_uuid,
274
+ placeable_type_placed_type_dictionary,
275
+ owning_repository_uuid,
276
+ presentation_name=presentation_name,
277
+ )
278
+
279
+ return bnop_placeabletype
280
+
281
+ @staticmethod
282
+ def create_bnop_type_place(
283
+ type_place_uuid,
284
+ placing_type,
285
+ placed_type,
286
+ type_place_ckid,
287
+ owning_repository_uuid,
288
+ ):
289
+ bnop_type_place = BnopTypePlaceFactories.create(
290
+ type_place_uuid,
291
+ placing_type,
292
+ placed_type,
293
+ type_place_ckid,
294
+ owning_repository_uuid,
295
+ )
296
+
297
+ return bnop_type_place
298
+
299
+ @staticmethod
300
+ def __add_placed_type_to_placeabletype(
301
+ placed_type,
302
+ place_number_ckid,
303
+ placeable_type,
304
+ ):
305
+ placeable_type.placeable_type_placed_types_dictionary[
306
+ place_number_ckid
307
+ ] = placed_type
File without changes
@@ -0,0 +1,42 @@
1
+ import shelve
2
+
3
+ from bnop.core.object_model.objects.bnop_objects import (
4
+ BnopObjects,
5
+ )
6
+
7
+
8
+ def write_bnop(full_filename: str):
9
+ bnop_shelf = shelve.open(
10
+ full_filename
11
+ )
12
+
13
+ bnop_shelf.clear_xml_model_branches()
14
+
15
+ for (
16
+ key,
17
+ value,
18
+ ) in (
19
+ BnopObjects.registry_keyed_on_uuid.items()
20
+ ):
21
+ bnop_shelf[key] = value
22
+
23
+ bnop_shelf.close()
24
+
25
+
26
+ def read_bnop(full_filename: str):
27
+ bnop_shelf = shelve.open(
28
+ full_filename
29
+ )
30
+
31
+ for (
32
+ key,
33
+ value,
34
+ ) in bnop_shelf.items():
35
+ print(
36
+ "Key: "
37
+ + key
38
+ + " - Type: "
39
+ + str(type(value).__name__)
40
+ )
41
+
42
+ bnop_shelf.close()
bnop/core/__init__.py ADDED
File without changes
File without changes
@@ -0,0 +1,16 @@
1
+ from bnop.core.object_model.objects.bnop_elements import (
2
+ BnopElements,
3
+ )
4
+
5
+
6
+ class BnopElementFactories:
7
+
8
+ @staticmethod
9
+ def create(
10
+ uuid, owning_repository_uuid
11
+ ):
12
+ bnop_element = BnopElements(
13
+ uuid, owning_repository_uuid
14
+ )
15
+
16
+ return bnop_element
@@ -0,0 +1,22 @@
1
+ from bnop.core.object_model.objects.bnop_names import (
2
+ BnopNames,
3
+ )
4
+
5
+
6
+ class BnopNameFactories:
7
+
8
+ @staticmethod
9
+ def create(
10
+ uuid,
11
+ exemplar_representation,
12
+ owning_repository_uuid,
13
+ presentation_name=str(),
14
+ ):
15
+ bnop_name = BnopNames(
16
+ uuid,
17
+ exemplar_representation,
18
+ owning_repository_uuid,
19
+ presentation_name=presentation_name,
20
+ )
21
+
22
+ return bnop_name
@@ -0,0 +1,29 @@
1
+ from bclearer_core.ckids.boro_object_ckids import (
2
+ BoroObjectCkIds,
3
+ )
4
+ from bnop.core.object_model.objects.bnop_objects import (
5
+ BnopObjects,
6
+ )
7
+
8
+
9
+ class BnopObjectFactories:
10
+ def __init__(self):
11
+ pass
12
+
13
+ @staticmethod
14
+ def create(
15
+ uuid,
16
+ owning_repository_uuid,
17
+ presentation_name=str(),
18
+ ):
19
+ bnop_object = BnopObjects(
20
+ uuid,
21
+ owning_repository_uuid,
22
+ presentation_name=presentation_name,
23
+ )
24
+
25
+ bnop_object.add_to_registry_keyed_on_ckid_type(
26
+ BoroObjectCkIds.Objects
27
+ )
28
+
29
+ return bnop_object
@@ -0,0 +1,22 @@
1
+ from bnop.core.object_model.objects.bnop_placeable_types import (
2
+ BnopPlaceableTypes,
3
+ )
4
+
5
+
6
+ class BnopPlaceableTypeFactories:
7
+
8
+ @staticmethod
9
+ def create(
10
+ uuid,
11
+ placeable_type_placed_types_dictionary,
12
+ owning_repository_uuid,
13
+ presentation_name=str(),
14
+ ):
15
+ bnop_placeabletype = BnopPlaceableTypes(
16
+ uuid,
17
+ placeable_type_placed_types_dictionary,
18
+ owning_repository_uuid,
19
+ presentation_name=presentation_name,
20
+ )
21
+
22
+ return bnop_placeabletype
@@ -0,0 +1,25 @@
1
+ from bclearer_core.ckids.boro_object_ckids import (
2
+ BoroObjectCkIds,
3
+ )
4
+ from bnop.core.object_model.objects.bnop_tuples import (
5
+ BnopTuples,
6
+ )
7
+
8
+
9
+ class BnopTupleFactories:
10
+
11
+ @staticmethod
12
+ def create(
13
+ uuid,
14
+ tuple_placed_objects_dictionary,
15
+ immutable_minor_composition_couple_type_boro_object_ckid: BoroObjectCkIds,
16
+ owning_repository_uuid,
17
+ ):
18
+ bnop_tuple = BnopTuples(
19
+ uuid,
20
+ tuple_placed_objects_dictionary,
21
+ immutable_minor_composition_couple_type_boro_object_ckid,
22
+ owning_repository_uuid,
23
+ )
24
+
25
+ return bnop_tuple
@@ -0,0 +1,26 @@
1
+ from bnop.core.factories.bnop_object_factories import (
2
+ BnopObjectFactories,
3
+ )
4
+ from bnop.core.object_model.objects.bnop_types import (
5
+ BnopTypes,
6
+ )
7
+
8
+
9
+ class BnopTypeFactories(
10
+ BnopObjectFactories
11
+ ):
12
+ pass
13
+
14
+ @staticmethod
15
+ def create(
16
+ uuid,
17
+ owning_repository_uuid,
18
+ presentation_name=str(),
19
+ ):
20
+ bnop_type = BnopTypes(
21
+ uuid,
22
+ owning_repository_uuid,
23
+ presentation_name=presentation_name,
24
+ )
25
+
26
+ return bnop_type
@@ -0,0 +1,26 @@
1
+ from bnop.core.object_model.objects.bnop_type_places import (
2
+ BnopTypePlaces,
3
+ )
4
+
5
+
6
+ class BnopTypePlaceFactories:
7
+
8
+ @staticmethod
9
+ def create(
10
+ uuid,
11
+ placing_type,
12
+ placed_type,
13
+ type_place_ckid,
14
+ owning_repository_uuid,
15
+ ):
16
+ bnop_type_place = (
17
+ BnopTypePlaces(
18
+ uuid,
19
+ placing_type,
20
+ placed_type,
21
+ type_place_ckid,
22
+ owning_repository_uuid,
23
+ )
24
+ )
25
+
26
+ return bnop_type_place
File without changes
@@ -0,0 +1,4 @@
1
+ class BnopRepositories(object):
2
+
3
+ def __init__(self, uuid):
4
+ self.uuid = uuid
File without changes
@@ -0,0 +1,26 @@
1
+ from bclearer_core.ckids.boro_object_ckids import (
2
+ BoroObjectCkIds,
3
+ )
4
+ from bnop.core.object_model.objects.bnop_objects import (
5
+ BnopObjects,
6
+ )
7
+
8
+
9
+ class BnopElements(BnopObjects):
10
+
11
+ def __init__(
12
+ self,
13
+ uuid,
14
+ owning_repository_uuid,
15
+ presentation_name=str(),
16
+ ):
17
+ BnopObjects.__init__(
18
+ self,
19
+ uuid,
20
+ owning_repository_uuid,
21
+ presentation_name=presentation_name,
22
+ )
23
+
24
+ self.add_to_registry_keyed_on_ckid_type(
25
+ BoroObjectCkIds.Elements
26
+ )
@@ -0,0 +1,29 @@
1
+ from bclearer_core.ckids.boro_object_ckids import (
2
+ BoroObjectCkIds,
3
+ )
4
+ from bnop.core.object_model.objects.bnop_representations import (
5
+ BnopRepresentations,
6
+ )
7
+
8
+
9
+ class BnopNames(BnopRepresentations):
10
+ def __init__(
11
+ self,
12
+ uuid,
13
+ exemplar_representation,
14
+ owning_repository_uuid,
15
+ presentation_name=str(),
16
+ ):
17
+ BnopRepresentations.__init__(
18
+ self,
19
+ uuid,
20
+ exemplar_representation,
21
+ owning_repository_uuid,
22
+ presentation_name=presentation_name,
23
+ )
24
+
25
+ self.naming_spaces = set()
26
+
27
+ self.add_to_registry_keyed_on_ckid_type(
28
+ BoroObjectCkIds.Names
29
+ )
@@ -0,0 +1,86 @@
1
+ from bclearer_core.ckids.boro_object_ckids import (
2
+ BoroObjectCkIds,
3
+ )
4
+
5
+
6
+ class BnopObjects(object):
7
+ registry_keyed_on_uuid = {}
8
+
9
+ registry_keyed_on_ckid_type = {}
10
+
11
+ matched_objects = []
12
+
13
+ def __init__(
14
+ self,
15
+ uuid,
16
+ owning_repository_uuid,
17
+ presentation_name=str(),
18
+ ):
19
+ self.uuid = uuid
20
+
21
+ self.registry_keyed_on_uuid.update(
22
+ {self.uuid: self}
23
+ )
24
+
25
+ self.owning_repository_uuid = (
26
+ owning_repository_uuid
27
+ )
28
+
29
+ self.is_named_bys = set()
30
+
31
+ self.names = set()
32
+
33
+ self.types = set()
34
+
35
+ self.instances = set()
36
+
37
+ self.supertypes = set()
38
+
39
+ self.subtypes = set()
40
+
41
+ self.uml_name = (
42
+ presentation_name
43
+ )
44
+
45
+ self.naming_spaces = set()
46
+
47
+ def add_to_registry_keyed_on_ckid_type(
48
+ self,
49
+ boro_object_ck_id: BoroObjectCkIds,
50
+ ):
51
+
52
+ if (
53
+ boro_object_ck_id
54
+ in self.registry_keyed_on_ckid_type
55
+ ):
56
+ ckid_typed_objects = self.registry_keyed_on_ckid_type[
57
+ boro_object_ck_id
58
+ ]
59
+ else:
60
+ ckid_typed_objects = set()
61
+
62
+ self.registry_keyed_on_ckid_type.update(
63
+ {
64
+ boro_object_ck_id: ckid_typed_objects
65
+ }
66
+ )
67
+
68
+ ckid_typed_objects.add(self)
69
+
70
+ @staticmethod
71
+ def import_bnop_object(bnop_object):
72
+ BnopObjects.registry_keyed_on_uuid.update(
73
+ {
74
+ bnop_object.uuid: bnop_object
75
+ }
76
+ )
77
+
78
+ return bnop_object
79
+
80
+ @staticmethod
81
+ def add_to_matched_objects(
82
+ bnop_object,
83
+ ):
84
+ BnopObjects.matched_objects.append(
85
+ bnop_object.uuid
86
+ )