pyegeria 5.4.0.3__py3-none-any.whl → 5.4.0.5__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.
- commands/cat/list_collections.py +37 -41
- commands/cat/list_format_set.py +411 -0
- commands/cli/debug_log +0 -0
- commands/cli/egeria.py +46 -34
- commands/cli/egeria_cat.py +46 -33
- commands/cli/ops_config.py +1 -4
- md_processing/dr-egeria-outbox/DataStruct-2025-07-29-20-49-16.py +8 -0
- md_processing/dr-egeria-outbox/Mandy-DataStruct-2025-07-29-15-54-45.md +19 -0
- pyegeria/__init__.py +1 -1
- pyegeria/_exceptions_new.py +29 -0
- pyegeria/_output_formats.py +109 -19
- pyegeria/collection_manager_omvs.py +25 -24
- pyegeria/data_designer_omvs.py +150 -127
- pyegeria/load_config.py +418 -144
- pyegeria/load_config_orig.py +218 -0
- pyegeria/logging_configuration.py +21 -15
- pyegeria/output_formatter.py +11 -2
- {pyegeria-5.4.0.3.dist-info → pyegeria-5.4.0.5.dist-info}/METADATA +2 -1
- {pyegeria-5.4.0.3.dist-info → pyegeria-5.4.0.5.dist-info}/RECORD +22 -17
- {pyegeria-5.4.0.3.dist-info → pyegeria-5.4.0.5.dist-info}/entry_points.txt +1 -0
- {pyegeria-5.4.0.3.dist-info → pyegeria-5.4.0.5.dist-info}/LICENSE +0 -0
- {pyegeria-5.4.0.3.dist-info → pyegeria-5.4.0.5.dist-info}/WHEEL +0 -0
pyegeria/_output_formats.py
CHANGED
@@ -5,18 +5,24 @@ Copyright Contributors to the ODPi Egeria project.
|
|
5
5
|
|
6
6
|
"""
|
7
7
|
# Purpose
|
8
|
+
This file manages output format sets.
|
9
|
+
|
8
10
|
pyegeria allows find and get requests to generate output in different output formats -
|
9
11
|
including DICT, MD, FORM, REPORT, LIST, MERMAID, TABLE, and perhaps additional ones in the future.
|
10
12
|
|
11
|
-
Some of the formats, such as REPORT and LIST,
|
13
|
+
Some of the formats, such as REPORT and LIST, allow the user to filter which attributes to
|
12
14
|
display, and the order in which they appear. However, many, if not most users will likely not want to customize
|
13
15
|
the column list and so we need a sensible set of defaults for each type of output. These defaults are used
|
14
16
|
by the find and get methods if the user doesn't provide a value for the columns parameter.
|
15
17
|
|
16
|
-
This file contains these defaults and a function to return the
|
17
|
-
|
18
|
+
This file contains these defaults and a function to return the right default dict for a given type.
|
18
19
|
"""
|
19
20
|
|
21
|
+
from loguru import logger
|
22
|
+
|
23
|
+
# Constants
|
24
|
+
MD_SEPARATOR = "\n---\n\n"
|
25
|
+
|
20
26
|
# Define shared elements
|
21
27
|
COMMON_COLUMNS = [
|
22
28
|
{'name': 'Display Name', 'key': 'display_name'},
|
@@ -49,6 +55,11 @@ COLLECTION_DICT = {
|
|
49
55
|
"columns": COLLECTIONS_COLUMNS,
|
50
56
|
}
|
51
57
|
|
58
|
+
COLLECTION_TABLE = {
|
59
|
+
"types": ["TABLE"],
|
60
|
+
"columns": COMMON_COLUMNS,
|
61
|
+
}
|
62
|
+
|
52
63
|
COMMON_ANNOTATIONS = {
|
53
64
|
"wikilinks": ["[[Commons]]"]
|
54
65
|
}
|
@@ -85,7 +96,11 @@ output_format_sets = {
|
|
85
96
|
"aliases": ["Collection", "RootCollection", "Folder", "ReferenceList", "HomeCollection",
|
86
97
|
"ResultSet", "RecentAccess", "WorkItemList", "Namespace"],
|
87
98
|
"annotations": COMMON_ANNOTATIONS,
|
88
|
-
"formats": [COMMON_FORMATS_ALL,
|
99
|
+
"formats": [ COLLECTION_DICT, COLLECTION_TABLE,COMMON_FORMATS_ALL], # Reusing common formats
|
100
|
+
"action": [{"function": "CollectionManager.find_collections",
|
101
|
+
"user_params": [ "search_string"],
|
102
|
+
"spec_params": { },
|
103
|
+
}]
|
89
104
|
},
|
90
105
|
|
91
106
|
"DigitalProducts": {
|
@@ -107,6 +122,11 @@ output_format_sets = {
|
|
107
122
|
{'name': 'Members', 'key': 'members', 'format': True},
|
108
123
|
],
|
109
124
|
}
|
125
|
+
],
|
126
|
+
"action": [{"function": "CollectionManager.find_collections",
|
127
|
+
"user_params": [ "search_string"],
|
128
|
+
"spec_params": { "classification_name":"DigitalProducts"}
|
129
|
+
}
|
110
130
|
]
|
111
131
|
},
|
112
132
|
|
@@ -115,30 +135,74 @@ output_format_sets = {
|
|
115
135
|
"description": "Attributes generic to all Agreements.",
|
116
136
|
"aliases": ["DataSharingAgreement"],
|
117
137
|
"annotations": {"wikilinks": ["[[Agreements]]", "[[Egeria]]"]},
|
118
|
-
"formats": COMMON_FORMATS_ALL
|
138
|
+
"formats": [COMMON_FORMATS_ALL] # Reusing common formats and columns
|
119
139
|
},
|
120
140
|
|
121
|
-
"
|
141
|
+
"DataDictionary": {
|
122
142
|
"heading": "Data Dictionary Information",
|
123
143
|
"description": "Attributes useful to Data Dictionary.",
|
124
|
-
"aliases": ["Data Dict"],
|
144
|
+
"aliases": ["Data Dict", "Data Dictionary"],
|
125
145
|
"annotations": {"wikilinks": ["[[Data Dictionary]]"]},
|
126
|
-
"formats": COMMON_FORMATS_ALL # Reusing common formats and columns
|
146
|
+
"formats": [COMMON_FORMATS_ALL], # Reusing common formats and columns
|
147
|
+
"action": [{"function": "CollectionManager.find_collections",
|
148
|
+
"user_params": [ "search_string"],
|
149
|
+
"spec_params": { "classification_name": "DataDictionary" },
|
150
|
+
}]
|
127
151
|
},
|
128
152
|
|
129
153
|
"Data Specification": {
|
130
154
|
"heading": "Data Specification Information",
|
131
155
|
"description": "Attributes useful to Data Specification.",
|
132
|
-
"aliases": ["Data Spec"],
|
156
|
+
"aliases": ["Data Spec", "DataSpec", "DataSpecification"],
|
133
157
|
"annotations": {"wikilinks": ["[[Data Specification]]"]},
|
134
|
-
"formats":
|
158
|
+
"formats": [{"types": ["DICT"], "columns": COMMON_COLUMNS,}], # Reusing common formats and columns
|
159
|
+
"action": [{"function": "CollectionManager.find_collections",
|
160
|
+
"user_params": [ "search_string"],
|
161
|
+
"spec_params": { "classification_name": "DataSpec" },
|
162
|
+
}]
|
163
|
+
},
|
164
|
+
"DataStruct": {
|
165
|
+
"heading": "Data Structure Information",
|
166
|
+
"description": "Attributes useful to Data Structures.",
|
167
|
+
"aliases": ["Data Structure", "DataStructures", "Data Structures", "Data Struct", "DataStructure"],
|
168
|
+
"annotations": {"wikilinks": ["[[Data Structure]]"]},
|
169
|
+
"formats": [{"types": ["ALL"], "columns" : COMMON_COLUMNS}], # Reusing common formats and columns
|
170
|
+
"action": [{"function": "DataDesigner.find_data_structures",
|
171
|
+
"user_params": ["search_string" ],
|
172
|
+
"spec_params": { },
|
173
|
+
}]
|
135
174
|
},
|
175
|
+
"DataField": {
|
176
|
+
"heading": "Data Structure Information",
|
177
|
+
"description": "Attributes useful to Data Structures.",
|
178
|
+
"aliases": ["Data Field", "Data Fields", "DataFields"],
|
179
|
+
"annotations": {"wikilinks": ["[[Data Field]]"]},
|
180
|
+
"formats": [{"types": ["ALL"], "columns" : COMMON_COLUMNS}], # Reusing common formats and columns
|
181
|
+
"action": [{"function": "DataDesigner.find_data_fields",
|
182
|
+
"user_params": ["search_string" ],
|
183
|
+
"spec_params": { },
|
184
|
+
}]
|
185
|
+
},
|
186
|
+
"Mandy-DataStruct": {
|
187
|
+
"heading": "Puddy Approves",
|
188
|
+
"description": "This is a tutorial on how to use a data struct description",
|
189
|
+
"aliases": [],
|
190
|
+
"annotations": {"wikilinks": ["[[Data Structure]]"]},
|
191
|
+
"formats": [{"types": ["TABLE"], "columns": COMMON_COLUMNS + [{'name': 'GUID', 'key': 'GUID'}]},
|
192
|
+
{ "types": ["DICT", "LIST", "REPORT"], "columns": COMMON_COLUMNS + [{'name': 'GUID', 'key': 'GUID'}]}
|
193
|
+
],
|
194
|
+
"action": [{
|
195
|
+
"function": "DataDesigner.find_data_structures",
|
196
|
+
"user_params": ["filter"],
|
197
|
+
"spec_params": {},
|
198
|
+
}]
|
199
|
+
},
|
136
200
|
}
|
137
201
|
|
138
|
-
|
139
202
|
def select_output_format_set(kind: str, output_type: str) -> dict | None:
|
140
203
|
"""
|
141
204
|
This function retrieves the appropriate output set configuration dictionary based on the `kind` and `output_type`.
|
205
|
+
If output_type = `ANY` that indicates this is just a test to see of the output format set exists.
|
142
206
|
|
143
207
|
:param kind: The kind of output set (e.g., "Referenceable", "Collections").
|
144
208
|
:param output_type: The desired output format type (e.g., "DICT", "LIST", "REPORT").
|
@@ -147,17 +211,14 @@ def select_output_format_set(kind: str, output_type: str) -> dict | None:
|
|
147
211
|
Returns:
|
148
212
|
dict | None:
|
149
213
|
"""
|
150
|
-
from loguru import logger
|
151
|
-
# from pyegeria.logging_configuration import config_logging
|
152
|
-
|
153
|
-
# config_logging()
|
154
|
-
|
155
214
|
# Normalize the output type to uppercase for consistency
|
215
|
+
output_sets = output_format_sets
|
216
|
+
|
156
217
|
output_type = output_type.upper()
|
157
218
|
output_struct:dict = {}
|
158
219
|
|
159
220
|
# Step 1: Check if `kind` exists in the `output_format_sets` dictionary
|
160
|
-
element =
|
221
|
+
element = output_sets.get(kind)
|
161
222
|
|
162
223
|
# Step 2: If not found, attempt to match `kind` in aliases
|
163
224
|
if element is None:
|
@@ -170,7 +231,7 @@ def select_output_format_set(kind: str, output_type: str) -> dict | None:
|
|
170
231
|
|
171
232
|
# Step 3: If still not found, return None
|
172
233
|
if element is None:
|
173
|
-
msg = "No matching column set found for kind='{kind}' and output type='{output_type}'."
|
234
|
+
msg = f"No matching column set found for kind='{kind}' and output type='{output_type}'."
|
174
235
|
logger.error(msg)
|
175
236
|
return None
|
176
237
|
else:
|
@@ -178,6 +239,12 @@ def select_output_format_set(kind: str, output_type: str) -> dict | None:
|
|
178
239
|
output_struct["heading"] = element.get("heading", [])
|
179
240
|
output_struct["description"] = element.get("description", [])
|
180
241
|
output_struct["annotations"] = element.get("annotations", {})
|
242
|
+
if "action" in element:
|
243
|
+
output_struct["action"] = element.get("action", [])
|
244
|
+
|
245
|
+
# If this was just a validation that the format set could be found then the output type is ANY - so just return.
|
246
|
+
if output_type == "ANY":
|
247
|
+
return output_struct
|
181
248
|
|
182
249
|
# Step 4: Search for a matching format in the `formats` list
|
183
250
|
for format in element.get("formats", []):
|
@@ -193,4 +260,27 @@ def select_output_format_set(kind: str, output_type: str) -> dict | None:
|
|
193
260
|
|
194
261
|
# Step 6: If no match is found, return None
|
195
262
|
logger.error(f"No matching format found for kind='{kind}' with output type='{output_type}'.")
|
196
|
-
return None
|
263
|
+
return None
|
264
|
+
|
265
|
+
def output_format_set_list()->list[str]:
|
266
|
+
return list(output_format_sets.keys())
|
267
|
+
|
268
|
+
def get_output_format_set_heading(format_set: dict) -> str:
|
269
|
+
return output_format_sets[format_set].get("heading")
|
270
|
+
def get_output_format_set_description(format_set: dict) -> str:
|
271
|
+
return output_format_sets[format_set].get("description")
|
272
|
+
|
273
|
+
def get_output_format_type_match(format_set: dict, output_format: str) -> dict:
|
274
|
+
if isinstance(format_set, list):
|
275
|
+
for format in format_set.get("formats", []):
|
276
|
+
if output_format in format.get("types", []):
|
277
|
+
format_set["formats"] = format
|
278
|
+
return format_set
|
279
|
+
|
280
|
+
# Step 5: Handle the fallback case of "ALL"
|
281
|
+
for format in format_set.get("formats", []):
|
282
|
+
if "ALL" in format.get("types", []):
|
283
|
+
format_set["formats"] = format
|
284
|
+
return format_set
|
285
|
+
else:
|
286
|
+
return format_set
|
@@ -11,7 +11,7 @@ from typing import Dict, Union, List, Optional
|
|
11
11
|
|
12
12
|
from loguru import logger
|
13
13
|
|
14
|
-
from pyegeria import select_output_format_set
|
14
|
+
from pyegeria._output_formats import select_output_format_set, get_output_format_type_match
|
15
15
|
from pyegeria._client import Client
|
16
16
|
from pyegeria._globals import NO_ELEMENTS_FOUND, NO_GUID_RETURNED, NO_MEMBERS_FOUND
|
17
17
|
from pyegeria._validators import validate_guid, validate_search_string
|
@@ -150,8 +150,8 @@ class CollectionManager(Client2):
|
|
150
150
|
|
151
151
|
if output_format != 'JSON': # return a simplified markdown representation
|
152
152
|
logger.info(f"Found elements, output format: {output_format}, output_format_set: {output_format_set}")
|
153
|
-
return self.
|
154
|
-
|
153
|
+
return self._generate_collection_output(elements, None, None, output_format,
|
154
|
+
output_format_set=output_format_set)
|
155
155
|
return elements
|
156
156
|
|
157
157
|
|
@@ -303,8 +303,8 @@ class CollectionManager(Client2):
|
|
303
303
|
|
304
304
|
if output_format != 'JSON': # return a simplified markdown representation
|
305
305
|
logger.info(f"Found elements, output format: {output_format}, output_format_set: {output_format_set}")
|
306
|
-
return self.
|
307
|
-
|
306
|
+
return self._generate_collection_output(elements, None, classification_name,
|
307
|
+
output_format, output_format_set)
|
308
308
|
return elements
|
309
309
|
|
310
310
|
|
@@ -549,8 +549,8 @@ class CollectionManager(Client2):
|
|
549
549
|
|
550
550
|
if output_format != 'JSON': # return a simplified markdown representation
|
551
551
|
logger.info(f"Found elements, output format: {output_format}, output_format_set: {output_format_set}")
|
552
|
-
return self.
|
553
|
-
|
552
|
+
return self._generate_collection_output(elements, filter, classification_name,
|
553
|
+
output_format, output_format_set)
|
554
554
|
return elements
|
555
555
|
|
556
556
|
|
@@ -687,8 +687,8 @@ class CollectionManager(Client2):
|
|
687
687
|
|
688
688
|
if output_format != 'JSON': # return a simplified markdown representation
|
689
689
|
logger.info(f"Found elements, output format: {output_format}, output_format_set: {output_format_set}")
|
690
|
-
return self.
|
691
|
-
|
690
|
+
return self._generate_collection_output(elements, filter, collection_type,
|
691
|
+
output_format, output_format_set)
|
692
692
|
return elements
|
693
693
|
|
694
694
|
|
@@ -818,8 +818,8 @@ class CollectionManager(Client2):
|
|
818
818
|
|
819
819
|
if output_format != 'JSON': # return a simplified markdown representation
|
820
820
|
logger.info(f"Found elements, output format: {output_format}, output_format_set: {output_format_set}")
|
821
|
-
return self.
|
822
|
-
|
821
|
+
return self._generate_collection_output(elements, None, collection_type,
|
822
|
+
output_format, output_format_set)
|
823
823
|
return elements
|
824
824
|
|
825
825
|
|
@@ -952,8 +952,8 @@ class CollectionManager(Client2):
|
|
952
952
|
|
953
953
|
if output_format != 'JSON': # return a simplified markdown representation
|
954
954
|
logger.debug(f"Found elements, output format: {output_format}, output_format_set: {output_format_set}")
|
955
|
-
return self.
|
956
|
-
|
955
|
+
return self._generate_collection_output(elements, None, None,
|
956
|
+
output_format, output_format_set)
|
957
957
|
return elements
|
958
958
|
|
959
959
|
|
@@ -1091,8 +1091,8 @@ class CollectionManager(Client2):
|
|
1091
1091
|
|
1092
1092
|
if output_format != 'JSON': # return a simplified markdown representation
|
1093
1093
|
logger.info(f"Found elements, output format: {output_format}, output_format_set: {output_format_set}")
|
1094
|
-
return self.
|
1095
|
-
|
1094
|
+
return self._generate_collection_output(elements, None, None,
|
1095
|
+
output_format, output_format_set)
|
1096
1096
|
return elements
|
1097
1097
|
|
1098
1098
|
|
@@ -1218,8 +1218,8 @@ class CollectionManager(Client2):
|
|
1218
1218
|
|
1219
1219
|
if output_format != 'JSON': # return a simplified markdown representation
|
1220
1220
|
logger.info(f"Found elements, output format: {output_format}, output_format_set: {output_format_set}")
|
1221
|
-
return self.
|
1222
|
-
|
1221
|
+
return self._generate_collection_output(elements, None, None,
|
1222
|
+
output_format, output_format_set)
|
1223
1223
|
return elements
|
1224
1224
|
|
1225
1225
|
|
@@ -6461,9 +6461,9 @@ class CollectionManager(Client2):
|
|
6461
6461
|
return props
|
6462
6462
|
|
6463
6463
|
|
6464
|
-
def
|
6465
|
-
|
6466
|
-
|
6464
|
+
def _generate_collection_output(self, elements: dict|list[dict], filter: Optional[str],
|
6465
|
+
classification_name: Optional[str], output_format: str = "DICT",
|
6466
|
+
output_format_set: dict | str = None) -> str| list[dict]:
|
6467
6467
|
""" Generate output for collections in the specified format.
|
6468
6468
|
|
6469
6469
|
Args:
|
@@ -6484,15 +6484,16 @@ class CollectionManager(Client2):
|
|
6484
6484
|
# First see if the user has specified an output_format_set - either a label or a dict
|
6485
6485
|
if output_format_set:
|
6486
6486
|
if isinstance(output_format_set, str):
|
6487
|
-
output_formats = select_output_format_set(
|
6487
|
+
output_formats = select_output_format_set(output_format_set, output_format)
|
6488
6488
|
if isinstance(output_format_set, dict):
|
6489
|
-
output_formats = output_format_set
|
6490
|
-
|
6489
|
+
output_formats = get_output_format_type_match(output_format_set, output_format)
|
6491
6490
|
# If no output_format was set, then use the classification_name to lookup the output format
|
6492
6491
|
elif classification_name:
|
6493
6492
|
output_formats = select_output_format_set(classification_name, output_format)
|
6494
6493
|
else:
|
6495
|
-
|
6494
|
+
# fallback to collections or entity type
|
6495
|
+
output_formats = select_output_format_set(entity_type,output_format)
|
6496
|
+
|
6496
6497
|
logger.trace(f"Executing generate_collection_output for {entity_type}: {output_formats}")
|
6497
6498
|
return generate_output(
|
6498
6499
|
elements,
|