pyegeria 5.4.8.6__py3-none-any.whl → 5.4.8.8__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.
- examples/Coco_config/README.md +19 -0
- examples/Coco_config/__init__.py +4 -0
- examples/Coco_config/config_cocoMDS1.py +108 -0
- examples/Coco_config/config_cocoMDS2.py +126 -0
- examples/Coco_config/config_cocoMDS3.py +109 -0
- examples/Coco_config/config_cocoMDS4.py +91 -0
- examples/Coco_config/config_cocoMDS5.py +116 -0
- examples/Coco_config/config_cocoMDS6.py +114 -0
- examples/Coco_config/config_cocoMDSx.py +119 -0
- examples/Coco_config/config_cocoView1.py +155 -0
- examples/Coco_config/config_coco_core.py +255 -0
- examples/Coco_config/config_coco_datalake.py +450 -0
- examples/Coco_config/config_exchangeDL01.py +106 -0
- examples/Coco_config/config_governDL01.py +80 -0
- examples/Coco_config/config_monitorDev01.py +60 -0
- examples/Coco_config/config_monitorGov01.py +194 -0
- examples/Coco_config/globals.py +154 -0
- examples/GeoSpatial Products Example.py +535 -0
- examples/Jupyter Notebooks/P-egeria-server-config.ipynb +2137 -0
- examples/Jupyter Notebooks/README.md +2 -0
- examples/Jupyter Notebooks/common/P-environment-check.ipynb +115 -0
- examples/Jupyter Notebooks/common/__init__.py +14 -0
- examples/Jupyter Notebooks/common/common-functions.ipynb +4694 -0
- examples/Jupyter Notebooks/common/environment-check.ipynb +53 -0
- examples/Jupyter Notebooks/common/globals.ipynb +184 -0
- examples/Jupyter Notebooks/common/globals.py +154 -0
- examples/Jupyter Notebooks/common/orig_globals.py +152 -0
- examples/format_sets/all_format_sets.json +910 -0
- examples/format_sets/custom_format_sets.json +268 -0
- examples/format_sets/subset_format_sets.json +187 -0
- examples/format_sets_save_load_example.py +294 -0
- examples/output_formats_example.py +193 -0
- md_processing/__init__.py +6 -0
- md_processing/data/commands.json +30640 -59579
- md_processing/dr_egeria.py +18 -0
- md_processing/md_commands/feedback_commands.py +763 -0
- md_processing/md_commands/project_commands.py +1 -1
- md_processing/md_processing_utils/md_processing_constants.py +134 -4
- pyegeria/__init__.py +1 -1
- pyegeria/_client_new.py +109 -12
- pyegeria/_globals.py +3 -2
- pyegeria/base_report_formats.py +17 -0
- pyegeria/format_set_executor.py +5 -2
- {pyegeria-5.4.8.6.dist-info → pyegeria-5.4.8.8.dist-info}/METADATA +1 -1
- {pyegeria-5.4.8.6.dist-info → pyegeria-5.4.8.8.dist-info}/RECORD +49 -16
- {pyegeria-5.4.8.6.dist-info → pyegeria-5.4.8.8.dist-info}/top_level.txt +1 -0
- {pyegeria-5.4.8.6.dist-info → pyegeria-5.4.8.8.dist-info}/WHEEL +0 -0
- {pyegeria-5.4.8.6.dist-info → pyegeria-5.4.8.8.dist-info}/entry_points.txt +0 -0
- {pyegeria-5.4.8.6.dist-info → pyegeria-5.4.8.8.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
Copyright Contributors to the ODPi Egeria project.
|
|
5
|
+
|
|
6
|
+
Example script demonstrating how to save and load format sets.
|
|
7
|
+
|
|
8
|
+
This script shows how to:
|
|
9
|
+
1. Create custom format sets
|
|
10
|
+
2. Save format sets to a file
|
|
11
|
+
3. Load format sets from a file
|
|
12
|
+
4. Use the loaded format sets
|
|
13
|
+
5. Work with the user format sets directory
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
import sys
|
|
17
|
+
import os
|
|
18
|
+
import json
|
|
19
|
+
from pathlib import Path
|
|
20
|
+
|
|
21
|
+
# Add the parent directory to the path so we can import the modules
|
|
22
|
+
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
23
|
+
|
|
24
|
+
from pyegeria._output_format_models import Column, Format, ActionParameter, FormatSet, FormatSetDict
|
|
25
|
+
from pyegeria.base_report_formats import (
|
|
26
|
+
report_specs,
|
|
27
|
+
save_report_specs,
|
|
28
|
+
load_report_specs,
|
|
29
|
+
USER_FORMAT_SETS_DIR,
|
|
30
|
+
select_report_spec,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
def create_custom_format_sets():
|
|
34
|
+
"""
|
|
35
|
+
Create custom format sets for the example.
|
|
36
|
+
|
|
37
|
+
Returns:
|
|
38
|
+
FormatSetDict: A dictionary of custom format sets
|
|
39
|
+
"""
|
|
40
|
+
print("\n=== Creating Custom Format Sets ===")
|
|
41
|
+
|
|
42
|
+
# Create common columns that will be used in multiple formats
|
|
43
|
+
common_columns = [
|
|
44
|
+
Column(name="ID", key="id"),
|
|
45
|
+
Column(name="Name", key="name"),
|
|
46
|
+
Column(name="Description", key="description", format=True),
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
# Create additional columns for specific formats
|
|
50
|
+
detail_columns = [
|
|
51
|
+
Column(name="Created By", key="created_by"),
|
|
52
|
+
Column(name="Created Date", key="created_date"),
|
|
53
|
+
Column(name="Modified By", key="modified_by"),
|
|
54
|
+
Column(name="Modified Date", key="modified_date"),
|
|
55
|
+
]
|
|
56
|
+
|
|
57
|
+
technical_columns = [
|
|
58
|
+
Column(name="Type", key="type"),
|
|
59
|
+
Column(name="Status", key="status"),
|
|
60
|
+
Column(name="Version", key="version"),
|
|
61
|
+
]
|
|
62
|
+
|
|
63
|
+
# Create formats that reuse and compose columns
|
|
64
|
+
table_format = Format(
|
|
65
|
+
types=["TABLE"],
|
|
66
|
+
columns=common_columns, # Basic columns for table view
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
detail_format = Format(
|
|
70
|
+
types=["DETAIL", "FORM"],
|
|
71
|
+
columns=common_columns + detail_columns, # Common columns plus detail columns
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
technical_format = Format(
|
|
75
|
+
types=["TECHNICAL", "DICT"],
|
|
76
|
+
columns=common_columns + technical_columns, # Common columns plus technical columns
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
full_format = Format(
|
|
80
|
+
types=["FULL", "REPORT"],
|
|
81
|
+
columns=common_columns + detail_columns + technical_columns, # All columns
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
# Create format sets that include the formats
|
|
85
|
+
product_format_set = FormatSet(
|
|
86
|
+
heading="Product Format Set",
|
|
87
|
+
description="A format set for product information",
|
|
88
|
+
aliases=["Product", "Products"],
|
|
89
|
+
formats=[table_format, detail_format, technical_format],
|
|
90
|
+
action=[
|
|
91
|
+
ActionParameter(
|
|
92
|
+
function="ProductManager.find_products",
|
|
93
|
+
required_params=["search_string"],
|
|
94
|
+
spec_params={},
|
|
95
|
+
)
|
|
96
|
+
],
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
customer_format_set = FormatSet(
|
|
100
|
+
heading="Customer Format Set",
|
|
101
|
+
description="A format set for customer information",
|
|
102
|
+
aliases=["Customer", "Customers"],
|
|
103
|
+
formats=[table_format, detail_format, full_format],
|
|
104
|
+
action=[
|
|
105
|
+
ActionParameter(
|
|
106
|
+
function="CustomerManager.find_customers",
|
|
107
|
+
required_params=["search_string"],
|
|
108
|
+
spec_params={},
|
|
109
|
+
)
|
|
110
|
+
],
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
# Create a FormatSetDict with the custom format sets
|
|
114
|
+
custom_format_sets = FormatSetDict({
|
|
115
|
+
"Product": product_format_set,
|
|
116
|
+
"Customer": customer_format_set,
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
print(f"Created {len(custom_format_sets)} custom format sets:")
|
|
120
|
+
for name, format_set in custom_format_sets.items():
|
|
121
|
+
print(f" - {name}: {format_set.heading}")
|
|
122
|
+
print(f" Description: {format_set.description}")
|
|
123
|
+
print(f" Aliases: {format_set.aliases}")
|
|
124
|
+
print(f" Number of formats: {len(format_set.formats)}")
|
|
125
|
+
|
|
126
|
+
return custom_format_sets
|
|
127
|
+
|
|
128
|
+
def save_format_sets_example(custom_format_sets):
|
|
129
|
+
"""
|
|
130
|
+
Example of saving format sets to a file.
|
|
131
|
+
|
|
132
|
+
Args:
|
|
133
|
+
custom_format_sets: The custom format sets to save
|
|
134
|
+
|
|
135
|
+
Returns:
|
|
136
|
+
str: The path to the saved file
|
|
137
|
+
"""
|
|
138
|
+
print("\n=== Saving Format Sets ===")
|
|
139
|
+
|
|
140
|
+
# Create a directory for the example files
|
|
141
|
+
example_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "format_sets")
|
|
142
|
+
os.makedirs(example_dir, exist_ok=True)
|
|
143
|
+
|
|
144
|
+
# Save all format sets to a file
|
|
145
|
+
all_format_sets_path = os.path.join(example_dir, "all_format_sets.json")
|
|
146
|
+
save_report_specs(all_format_sets_path)
|
|
147
|
+
print(f"Saved all format sets to {all_format_sets_path}")
|
|
148
|
+
|
|
149
|
+
# Save only the custom format sets to a file
|
|
150
|
+
custom_format_sets_path = os.path.join(example_dir, "custom_format_sets.json")
|
|
151
|
+
custom_format_sets.save_to_json(custom_format_sets_path)
|
|
152
|
+
print(f"Saved custom format sets to {custom_format_sets_path}")
|
|
153
|
+
|
|
154
|
+
# Save a subset of the predefined format sets to a file
|
|
155
|
+
subset_format_sets_path = os.path.join(example_dir, "subset_format_sets.json")
|
|
156
|
+
save_report_specs(subset_format_sets_path, format_set_names=["Collections", "DataDictionary"])
|
|
157
|
+
print(f"Saved subset of format sets to {subset_format_sets_path}")
|
|
158
|
+
|
|
159
|
+
return custom_format_sets_path
|
|
160
|
+
|
|
161
|
+
def load_format_sets_example(file_path):
|
|
162
|
+
"""
|
|
163
|
+
Example of loading format sets from a file.
|
|
164
|
+
|
|
165
|
+
Args:
|
|
166
|
+
file_path: The path to the file to load
|
|
167
|
+
|
|
168
|
+
Returns:
|
|
169
|
+
FormatSetDict: The loaded format sets
|
|
170
|
+
"""
|
|
171
|
+
print("\n=== Loading Format Sets ===")
|
|
172
|
+
|
|
173
|
+
# Create a new FormatSetDict to load the format sets into
|
|
174
|
+
loaded_format_sets = FormatSetDict()
|
|
175
|
+
|
|
176
|
+
# Load the format sets from the file
|
|
177
|
+
try:
|
|
178
|
+
loaded_format_sets = FormatSetDict.load_from_json(file_path)
|
|
179
|
+
print(f"Loaded {len(loaded_format_sets)} format sets from {file_path}")
|
|
180
|
+
|
|
181
|
+
# Print information about the loaded format sets
|
|
182
|
+
for name, format_set in loaded_format_sets.items():
|
|
183
|
+
print(f" - {name}: {format_set.heading}")
|
|
184
|
+
print(f" Description: {format_set.description}")
|
|
185
|
+
print(f" Aliases: {format_set.aliases}")
|
|
186
|
+
print(f" Number of formats: {len(format_set.formats)}")
|
|
187
|
+
|
|
188
|
+
return loaded_format_sets
|
|
189
|
+
except Exception as e:
|
|
190
|
+
print(f"Error loading format sets from {file_path}: {e}")
|
|
191
|
+
return None
|
|
192
|
+
|
|
193
|
+
def use_loaded_format_sets(loaded_format_sets):
|
|
194
|
+
"""
|
|
195
|
+
Example of using loaded format sets.
|
|
196
|
+
|
|
197
|
+
Args:
|
|
198
|
+
loaded_format_sets: The loaded format sets to use
|
|
199
|
+
"""
|
|
200
|
+
print("\n=== Using Loaded Format Sets ===")
|
|
201
|
+
|
|
202
|
+
# Add the loaded format sets to the global report_specs
|
|
203
|
+
for name, format_set in loaded_format_sets.items():
|
|
204
|
+
report_specs[name] = format_set
|
|
205
|
+
|
|
206
|
+
# Use the select_report_spec function to get a format set by name
|
|
207
|
+
product_format_set = select_report_spec("Product", "TABLE")
|
|
208
|
+
if product_format_set:
|
|
209
|
+
print(f"Found format set for 'Product' with output type 'TABLE'")
|
|
210
|
+
print(f" Heading: {product_format_set['heading']}")
|
|
211
|
+
print(f" Description: {product_format_set['description']}")
|
|
212
|
+
print(f" Number of columns: {len(product_format_set['formats']['columns'])}")
|
|
213
|
+
else:
|
|
214
|
+
print("Format set for 'Product' not found")
|
|
215
|
+
|
|
216
|
+
# Use the select_report_spec function to get a format set by alias
|
|
217
|
+
customer_format_set = select_report_spec("Customers", "DETAIL")
|
|
218
|
+
if customer_format_set:
|
|
219
|
+
print(f"Found format set for 'Customers' with output type 'DETAIL'")
|
|
220
|
+
print(f" Heading: {customer_format_set['heading']}")
|
|
221
|
+
print(f" Description: {customer_format_set['description']}")
|
|
222
|
+
print(f" Number of columns: {len(customer_format_set['formats']['columns'])}")
|
|
223
|
+
else:
|
|
224
|
+
print("Format set for 'Customers' not found")
|
|
225
|
+
|
|
226
|
+
def user_format_sets_directory_example(custom_format_sets):
|
|
227
|
+
"""
|
|
228
|
+
Example of working with the user format sets directory.
|
|
229
|
+
|
|
230
|
+
Args:
|
|
231
|
+
custom_format_sets: The custom format sets to save to the user directory
|
|
232
|
+
"""
|
|
233
|
+
print("\n=== Working with User Format Sets Directory ===")
|
|
234
|
+
|
|
235
|
+
# Create the user format sets directory if it doesn't exist
|
|
236
|
+
os.makedirs(USER_FORMAT_SETS_DIR, exist_ok=True)
|
|
237
|
+
print(f"User format sets directory: {USER_FORMAT_SETS_DIR}")
|
|
238
|
+
|
|
239
|
+
# Save a custom format set to the user directory
|
|
240
|
+
user_format_set = FormatSet(
|
|
241
|
+
heading="User Custom Format Set",
|
|
242
|
+
description="A custom format set for the user directory",
|
|
243
|
+
formats=[
|
|
244
|
+
Format(
|
|
245
|
+
types=["TABLE"],
|
|
246
|
+
columns=[
|
|
247
|
+
Column(name="Column 1", key="column1"),
|
|
248
|
+
Column(name="Column 2", key="column2"),
|
|
249
|
+
],
|
|
250
|
+
),
|
|
251
|
+
],
|
|
252
|
+
)
|
|
253
|
+
|
|
254
|
+
user_format_sets = FormatSetDict({"UserCustomFormatSet": user_format_set})
|
|
255
|
+
user_format_sets_path = os.path.join(USER_FORMAT_SETS_DIR, "user_custom_format_sets.json")
|
|
256
|
+
user_format_sets.save_to_json(user_format_sets_path)
|
|
257
|
+
print(f"Saved user custom format set to {user_format_sets_path}")
|
|
258
|
+
|
|
259
|
+
# Load the user format sets
|
|
260
|
+
from pyegeria.base_report_formats import load_user_report_specs
|
|
261
|
+
load_user_report_specs()
|
|
262
|
+
|
|
263
|
+
# Check if the user format set was loaded
|
|
264
|
+
if "UserCustomFormatSet" in report_specs:
|
|
265
|
+
print("User custom format set was successfully loaded")
|
|
266
|
+
print(f" Heading: {report_specs['UserCustomFormatSet'].heading}")
|
|
267
|
+
print(f" Description: {report_specs['UserCustomFormatSet'].description}")
|
|
268
|
+
else:
|
|
269
|
+
print("User custom format set was not loaded")
|
|
270
|
+
|
|
271
|
+
def main():
|
|
272
|
+
"""Run the example."""
|
|
273
|
+
print("=== Format Sets Save/Load Example ===")
|
|
274
|
+
|
|
275
|
+
# Create custom format sets
|
|
276
|
+
custom_format_sets = create_custom_format_sets()
|
|
277
|
+
|
|
278
|
+
# Save format sets to files
|
|
279
|
+
file_path = save_format_sets_example(custom_format_sets)
|
|
280
|
+
|
|
281
|
+
# Load format sets from a file
|
|
282
|
+
loaded_format_sets = load_format_sets_example(file_path)
|
|
283
|
+
|
|
284
|
+
# Use the loaded format sets
|
|
285
|
+
if loaded_format_sets:
|
|
286
|
+
use_loaded_format_sets(loaded_format_sets)
|
|
287
|
+
|
|
288
|
+
# Work with the user format sets directory
|
|
289
|
+
user_format_sets_directory_example(custom_format_sets)
|
|
290
|
+
|
|
291
|
+
print("\n=== Example Complete ===")
|
|
292
|
+
|
|
293
|
+
if __name__ == "__main__":
|
|
294
|
+
main()
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
Copyright Contributors to the ODPi Egeria project.
|
|
5
|
+
|
|
6
|
+
Example script demonstrating how to use the Pydantic models for output formats.
|
|
7
|
+
|
|
8
|
+
This script shows how to:
|
|
9
|
+
1. Create custom columns, formats, and format sets
|
|
10
|
+
2. Compose formats by reusing columns
|
|
11
|
+
3. Add a custom format set to the report_specs dictionary
|
|
12
|
+
4. Use the functions in _output_formats.py with the new models
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
import sys
|
|
16
|
+
import os
|
|
17
|
+
|
|
18
|
+
# Add the parent directory to the path so we can import the modules
|
|
19
|
+
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
20
|
+
|
|
21
|
+
from pyegeria._output_format_models import Column, Format, ActionParameter, FormatSet
|
|
22
|
+
from pyegeria.base_report_formats import (
|
|
23
|
+
report_specs,
|
|
24
|
+
select_report_spec,
|
|
25
|
+
report_spec_list,
|
|
26
|
+
get_report_spec_heading,
|
|
27
|
+
get_report_spec_description,
|
|
28
|
+
get_report_spec_match,
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
def create_custom_format_set():
|
|
32
|
+
"""
|
|
33
|
+
Create a custom format set with multiple formats.
|
|
34
|
+
|
|
35
|
+
This demonstrates how to create columns, formats, and format sets,
|
|
36
|
+
and how to compose formats by reusing columns.
|
|
37
|
+
"""
|
|
38
|
+
print("\n=== Creating a custom format set ===")
|
|
39
|
+
|
|
40
|
+
# Create common columns that will be used in multiple formats
|
|
41
|
+
common_columns = [
|
|
42
|
+
Column(name="ID", key="id"),
|
|
43
|
+
Column(name="Name", key="name"),
|
|
44
|
+
Column(name="Description", key="description", format=True),
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
# Create additional columns for specific formats
|
|
48
|
+
detail_columns = [
|
|
49
|
+
Column(name="Created By", key="created_by"),
|
|
50
|
+
Column(name="Created Date", key="created_date"),
|
|
51
|
+
Column(name="Modified By", key="modified_by"),
|
|
52
|
+
Column(name="Modified Date", key="modified_date"),
|
|
53
|
+
]
|
|
54
|
+
|
|
55
|
+
technical_columns = [
|
|
56
|
+
Column(name="Type", key="type"),
|
|
57
|
+
Column(name="Status", key="status"),
|
|
58
|
+
Column(name="Version", key="version"),
|
|
59
|
+
]
|
|
60
|
+
|
|
61
|
+
# Create formats that reuse and compose columns
|
|
62
|
+
table_format = Format(
|
|
63
|
+
types=["TABLE"],
|
|
64
|
+
columns=common_columns, # Basic columns for table view
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
detail_format = Format(
|
|
68
|
+
types=["DETAIL", "FORM"],
|
|
69
|
+
columns=common_columns + detail_columns, # Common columns plus detail columns
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
technical_format = Format(
|
|
73
|
+
types=["TECHNICAL", "DICT"],
|
|
74
|
+
columns=common_columns + technical_columns, # Common columns plus technical columns
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
full_format = Format(
|
|
78
|
+
types=["FULL", "REPORT"],
|
|
79
|
+
columns=common_columns + detail_columns + technical_columns, # All columns
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
# Create a format set that includes all the formats
|
|
83
|
+
custom_format_set = FormatSet(
|
|
84
|
+
heading="Custom Example Format Set",
|
|
85
|
+
description="A custom format set demonstrating composition of formats",
|
|
86
|
+
aliases=["CustomExample", "Example"],
|
|
87
|
+
annotations={"wikilinks": ["[[Example]]", "[[Custom]]"]},
|
|
88
|
+
formats=[table_format, detail_format, technical_format, full_format],
|
|
89
|
+
action=[
|
|
90
|
+
ActionParameter(
|
|
91
|
+
function="ExampleManager.find_examples",
|
|
92
|
+
required_params=["search_string"],
|
|
93
|
+
spec_params={},
|
|
94
|
+
)
|
|
95
|
+
],
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
# Print information about the format set
|
|
99
|
+
print(f"Created format set: {custom_format_set.heading}")
|
|
100
|
+
print(f"Description: {custom_format_set.description}")
|
|
101
|
+
print(f"Aliases: {custom_format_set.aliases}")
|
|
102
|
+
print(f"Number of formats: {len(custom_format_set.formats)}")
|
|
103
|
+
|
|
104
|
+
# Print information about each format
|
|
105
|
+
for i, format in enumerate(custom_format_set.formats):
|
|
106
|
+
print(f"\nFormat {i+1}:")
|
|
107
|
+
print(f" Types: {format.types}")
|
|
108
|
+
print(f" Number of columns: {len(format.columns)}")
|
|
109
|
+
print(f" Columns: {[column.name for column in format.columns]}")
|
|
110
|
+
|
|
111
|
+
return custom_format_set
|
|
112
|
+
|
|
113
|
+
def add_format_set_to_dictionary(format_set):
|
|
114
|
+
"""
|
|
115
|
+
Add a format set to the report_specs dictionary.
|
|
116
|
+
|
|
117
|
+
This demonstrates how to add a custom format set to the
|
|
118
|
+
report_specs dictionary for use with the functions
|
|
119
|
+
in _output_formats.py.
|
|
120
|
+
"""
|
|
121
|
+
print("\n=== Adding format set to dictionary ===")
|
|
122
|
+
|
|
123
|
+
# Add the format set to the report_specs dictionary
|
|
124
|
+
report_specs["CustomExample"] = format_set
|
|
125
|
+
|
|
126
|
+
# Verify that the format set was added
|
|
127
|
+
format_sets = report_spec_list()
|
|
128
|
+
if "CustomExample" in format_sets:
|
|
129
|
+
print("Format set successfully added to the dictionary!")
|
|
130
|
+
print(f"Available format sets: {format_sets}")
|
|
131
|
+
else:
|
|
132
|
+
print("Failed to add format set to the dictionary.")
|
|
133
|
+
|
|
134
|
+
def use_output_format_functions():
|
|
135
|
+
"""
|
|
136
|
+
Use the functions in _output_formats.py with the new models.
|
|
137
|
+
|
|
138
|
+
This demonstrates how to use the functions in _output_formats.py
|
|
139
|
+
with the new Pydantic models.
|
|
140
|
+
"""
|
|
141
|
+
print("\n=== Using output format functions ===")
|
|
142
|
+
|
|
143
|
+
# Get a format set by name
|
|
144
|
+
format_set = select_report_spec("CustomExample", "TABLE")
|
|
145
|
+
if format_set:
|
|
146
|
+
print("Successfully retrieved format set by name!")
|
|
147
|
+
print(f"Heading: {format_set['heading']}")
|
|
148
|
+
print(f"Description: {format_set['description']}")
|
|
149
|
+
else:
|
|
150
|
+
print("Failed to retrieve format set by name.")
|
|
151
|
+
|
|
152
|
+
# Get a format set by alias
|
|
153
|
+
format_set = select_report_spec("Example", "TABLE")
|
|
154
|
+
if format_set:
|
|
155
|
+
print("\nSuccessfully retrieved format set by alias!")
|
|
156
|
+
print(f"Heading: {format_set['heading']}")
|
|
157
|
+
print(f"Description: {format_set['description']}")
|
|
158
|
+
else:
|
|
159
|
+
print("\nFailed to retrieve format set by alias.")
|
|
160
|
+
|
|
161
|
+
# Get the heading and description of a format set
|
|
162
|
+
heading = get_report_spec_heading("CustomExample")
|
|
163
|
+
description = get_report_spec_description("CustomExample")
|
|
164
|
+
print(f"\nHeading: {heading}")
|
|
165
|
+
print(f"Description: {description}")
|
|
166
|
+
|
|
167
|
+
# Match a format set with a specific output type
|
|
168
|
+
format_set = select_report_spec("CustomExample", "ANY")
|
|
169
|
+
matched_format_set = get_report_spec_match(format_set, "DETAIL")
|
|
170
|
+
if matched_format_set and "formats" in matched_format_set:
|
|
171
|
+
print("\nSuccessfully matched format set with output type!")
|
|
172
|
+
print(f"Output type: {matched_format_set['formats']['types']}")
|
|
173
|
+
print(f"Number of columns: {len(matched_format_set['formats']['columns'])}")
|
|
174
|
+
else:
|
|
175
|
+
print("\nFailed to match format set with output type.")
|
|
176
|
+
|
|
177
|
+
def main():
|
|
178
|
+
"""Run the example script."""
|
|
179
|
+
print("=== Output Formats Example ===")
|
|
180
|
+
|
|
181
|
+
# Create a custom format set
|
|
182
|
+
custom_format_set = create_custom_format_set()
|
|
183
|
+
|
|
184
|
+
# Add the format set to the report_specs dictionary
|
|
185
|
+
add_format_set_to_dictionary(custom_format_set)
|
|
186
|
+
|
|
187
|
+
# Use the functions in _output_formats.py with the new models
|
|
188
|
+
use_output_format_functions()
|
|
189
|
+
|
|
190
|
+
print("\n=== Example Complete ===")
|
|
191
|
+
|
|
192
|
+
if __name__ == "__main__":
|
|
193
|
+
main()
|
md_processing/__init__.py
CHANGED
|
@@ -32,6 +32,12 @@ from md_processing.md_commands.data_designer_commands import (process_data_field
|
|
|
32
32
|
process_data_dict_upsert_command,
|
|
33
33
|
process_data_structure_upsert_command)
|
|
34
34
|
|
|
35
|
+
from md_processing.md_commands.feedback_commands import (process_add_comment_command, process_upsert_note_log_command,
|
|
36
|
+
process_upsert_note_command, process_attach_note_log_command,
|
|
37
|
+
process_upsert_informal_tag_command, process_tag_element_command)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
35
41
|
from md_processing.md_commands.glossary_commands import (process_glossary_upsert_command,
|
|
36
42
|
process_term_upsert_command,
|
|
37
43
|
process_link_term_term_relationship_command,
|