pyegeria 5.4.0.dev11__py3-none-any.whl → 5.4.0.dev12__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/debug_log +6004 -19655
- commands/cat/debug_log.2025-07-01_15-22-20_102237.zip +0 -0
- commands/cat/debug_log.2025-07-04_15-43-28_460900.zip +0 -0
- commands/cat/debug_log.2025-07-06_20-48-04_338314.zip +0 -0
- commands/cat/debug_log.2025-07-09_10-17-09_526262.zip +0 -0
- commands/cat/dr_egeria_md.py +23 -13
- commands/cat/list_collections.py +9 -2
- md_processing/__init__.py +3 -1
- md_processing/data/commands.json +7842 -2231
- md_processing/md_commands/data_designer_commands.py +29 -19
- md_processing/md_commands/glossary_commands.py +3 -1
- md_processing/md_commands/product_manager_commands.py +1746 -0
- md_processing/md_commands/solution_architect_commands.py +390 -236
- md_processing/md_processing_utils/common_md_proc_utils.py +7 -5
- md_processing/md_processing_utils/md_processing_constants.py +25 -4
- pyegeria/__init__.py +1 -0
- pyegeria/_client.py +0 -1
- pyegeria/collection_manager_omvs.py +156 -117
- pyegeria/data_designer_omvs.py +16 -8
- pyegeria/egeria_tech_client.py +9 -25
- pyegeria/governance_officer_omvs.py +1446 -1343
- pyegeria/output_formatter.py +96 -8
- pyegeria/solution_architect_omvs.py +2278 -1728
- {pyegeria-5.4.0.dev11.dist-info → pyegeria-5.4.0.dev12.dist-info}/METADATA +1 -1
- {pyegeria-5.4.0.dev11.dist-info → pyegeria-5.4.0.dev12.dist-info}/RECORD +28 -23
- {pyegeria-5.4.0.dev11.dist-info → pyegeria-5.4.0.dev12.dist-info}/LICENSE +0 -0
- {pyegeria-5.4.0.dev11.dist-info → pyegeria-5.4.0.dev12.dist-info}/WHEEL +0 -0
- {pyegeria-5.4.0.dev11.dist-info → pyegeria-5.4.0.dev12.dist-info}/entry_points.txt +0 -0
pyegeria/output_formatter.py
CHANGED
@@ -1,11 +1,74 @@
|
|
1
1
|
from datetime import datetime
|
2
|
+
import re
|
2
3
|
from typing import Any, Callable, Dict, List, Optional, Tuple, Union
|
4
|
+
|
5
|
+
from markdown_it import MarkdownIt
|
3
6
|
from rich.console import Console
|
4
7
|
|
8
|
+
from pyegeria.mermaid_utilities import construct_mermaid_web
|
9
|
+
|
5
10
|
console = Console(width= 250)
|
6
11
|
# Constants
|
7
12
|
MD_SEPARATOR = "\n---\n\n"
|
8
13
|
|
14
|
+
def markdown_to_html(markdown_text: str) -> str:
|
15
|
+
"""
|
16
|
+
Convert markdown text to HTML, with special handling for mermaid code blocks.
|
17
|
+
|
18
|
+
Args:
|
19
|
+
markdown_text: The markdown text to convert
|
20
|
+
|
21
|
+
Returns:
|
22
|
+
HTML string
|
23
|
+
"""
|
24
|
+
# Initialize markdown-it
|
25
|
+
md = MarkdownIt()
|
26
|
+
|
27
|
+
# Find all mermaid code blocks
|
28
|
+
mermaid_blocks = re.findall(r'```mermaid\n(.*?)\n```', markdown_text, re.DOTALL)
|
29
|
+
|
30
|
+
# Replace each mermaid block with a placeholder
|
31
|
+
placeholders = []
|
32
|
+
for i, block in enumerate(mermaid_blocks):
|
33
|
+
placeholder = f"MERMAID_PLACEHOLDER_{i}"
|
34
|
+
markdown_text = markdown_text.replace(f"```mermaid\n{block}\n```", placeholder)
|
35
|
+
placeholders.append((placeholder, block))
|
36
|
+
|
37
|
+
# Convert markdown to HTML
|
38
|
+
html_text = md.render(markdown_text)
|
39
|
+
|
40
|
+
# Replace placeholders with rendered mermaid HTML
|
41
|
+
for placeholder, mermaid_block in placeholders:
|
42
|
+
mermaid_html = construct_mermaid_web(mermaid_block)
|
43
|
+
html_text = html_text.replace(placeholder, mermaid_html)
|
44
|
+
|
45
|
+
# Add basic HTML structure
|
46
|
+
html_text = f"""
|
47
|
+
<!DOCTYPE html>
|
48
|
+
<html>
|
49
|
+
<head>
|
50
|
+
<meta charset="UTF-8">
|
51
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
52
|
+
<title>Egeria Report</title>
|
53
|
+
<style>
|
54
|
+
body {{ font-family: Arial, sans-serif; line-height: 1.6; padding: 20px; }}
|
55
|
+
h1 {{ color: #2c3e50; }}
|
56
|
+
h2 {{ color: #3498db; }}
|
57
|
+
pre {{ background-color: #f8f8f8; padding: 10px; border-radius: 5px; overflow-x: auto; }}
|
58
|
+
table {{ border-collapse: collapse; width: 100%; margin-bottom: 20px; }}
|
59
|
+
th, td {{ border: 1px solid #ddd; padding: 8px; text-align: left; }}
|
60
|
+
th {{ background-color: #f2f2f2; }}
|
61
|
+
tr:nth-child(even) {{ background-color: #f9f9f9; }}
|
62
|
+
</style>
|
63
|
+
</head>
|
64
|
+
<body>
|
65
|
+
{html_text}
|
66
|
+
</body>
|
67
|
+
</html>
|
68
|
+
"""
|
69
|
+
|
70
|
+
return html_text
|
71
|
+
|
9
72
|
def make_preamble(obj_type: str, search_string: str, output_format: str = 'MD') -> Tuple[str, Optional[str]]:
|
10
73
|
"""
|
11
74
|
Creates a preamble string and an elements action based on the given object type, search string,
|
@@ -68,12 +131,13 @@ def make_md_attribute(attribute_name: str, attribute_value: str, output_type: st
|
|
68
131
|
attribute_title = ""
|
69
132
|
|
70
133
|
if output_type in ["FORM", "MD"]:
|
71
|
-
if attribute_name.lower()
|
72
|
-
return
|
134
|
+
if attribute_name.lower() in [ "mermaid", "links", "implemented by", "sub_components"]:
|
135
|
+
return '\n'
|
136
|
+
|
73
137
|
output = f"## {attribute_title}\n{attribute_value}\n\n"
|
74
138
|
elif output_type == "REPORT":
|
75
139
|
if attribute_title in ['Mermaid Graph', 'Mermaid']:
|
76
|
-
output = f"## Mermaid Graph\n```mermaid\n{attribute_value}\n```\n"
|
140
|
+
output = f"## Mermaid Graph\n\n```mermaid\n{attribute_value}\n```\n"
|
77
141
|
elif attribute_value:
|
78
142
|
output = f"## {attribute_title}\n{attribute_value}\n\n"
|
79
143
|
return output
|
@@ -92,6 +156,8 @@ def format_for_markdown_table(text: str, guid: str = None) -> str:
|
|
92
156
|
if not text:
|
93
157
|
return ""
|
94
158
|
# Replace newlines with spaces and escape pipe characters
|
159
|
+
if isinstance(text, list):
|
160
|
+
text = "\n".join(text)
|
95
161
|
t = text.replace("\n", " ").replace("|", "\\|")
|
96
162
|
if '::' in t and guid:
|
97
163
|
t = f" [{t}](#{guid}) "
|
@@ -130,18 +196,26 @@ def generate_entity_md(elements: List[Dict],
|
|
130
196
|
if get_additional_props_func:
|
131
197
|
additional_props = get_additional_props_func(element,props['GUID'], output_format)
|
132
198
|
|
199
|
+
display_name = props.get('displayName', None)
|
200
|
+
if display_name is None:
|
201
|
+
display_name = props.get('title', None)
|
202
|
+
if display_name is None:
|
203
|
+
display_name = "NO DISPLAY NAME"
|
133
204
|
|
134
205
|
# Format header based on output format
|
135
206
|
if output_format in ['FORM', 'MD']:
|
136
207
|
elements_md += f"# {elements_action}\n\n"
|
137
|
-
elements_md += f"## {entity_type} Name \n\n{
|
208
|
+
elements_md += f"## {entity_type} Name \n\n{display_name}\n\n"
|
138
209
|
elif output_format == 'REPORT':
|
139
|
-
elements_md += f'<a id="{props["GUID"]}"></a>\n\n# {entity_type} Name: {
|
210
|
+
elements_md += f'<a id="{props["GUID"]}"></a>\n\n# {entity_type} Name: {display_name}\n\n'
|
140
211
|
else:
|
141
|
-
elements_md += f"## {entity_type} Name \n\n{
|
212
|
+
elements_md += f"## {entity_type} Name \n\n{display_name}\n\n"
|
142
213
|
|
143
214
|
# Add common attributes
|
144
215
|
for key, value in props.items():
|
216
|
+
if output_format in ['FORM', 'MD', 'DICT'] and key == 'mermaid':
|
217
|
+
continue
|
218
|
+
|
145
219
|
if key not in [ 'properties', 'display_name']:
|
146
220
|
elements_md += make_md_attribute(key.replace('_', ' '), value, output_format)
|
147
221
|
|
@@ -269,7 +343,7 @@ def generate_entity_dict(elements: List[Dict],
|
|
269
343
|
|
270
344
|
# Add properties based on include/exclude lists
|
271
345
|
for key, value in props.items():
|
272
|
-
if key
|
346
|
+
if key not in [ 'properties', 'mermaid']: # Skip the raw properties object
|
273
347
|
if (include_keys is None or key in include_keys) and (
|
274
348
|
exclude_keys is None or key not in exclude_keys):
|
275
349
|
entity_dict[key] = value
|
@@ -363,7 +437,7 @@ def generate_output(elements: Union[Dict, List[Dict]],
|
|
363
437
|
elements: Dictionary or list of dictionaries containing element data
|
364
438
|
search_string: The search string used to find the elements
|
365
439
|
entity_type: The type of entity (e.g., "Glossary", "Term", "Category")
|
366
|
-
output_format: The desired output format (MD, FORM, REPORT, LIST, DICT, MERMAID)
|
440
|
+
output_format: The desired output format (MD, FORM, REPORT, LIST, DICT, MERMAID, HTML)
|
367
441
|
extract_properties_func: Function to extract properties from an element
|
368
442
|
get_additional_props_func: Optional function to get additional properties
|
369
443
|
columns: Optional list of column definitions for table output
|
@@ -383,6 +457,20 @@ def generate_output(elements: Union[Dict, List[Dict]],
|
|
383
457
|
if output_format == 'MERMAID':
|
384
458
|
return extract_mermaid_only(elements)
|
385
459
|
|
460
|
+
elif output_format == 'HTML':
|
461
|
+
# First generate the REPORT format output
|
462
|
+
report_output = generate_output(
|
463
|
+
elements=elements,
|
464
|
+
search_string=search_string,
|
465
|
+
entity_type=entity_type,
|
466
|
+
output_format="REPORT",
|
467
|
+
extract_properties_func=extract_properties_func,
|
468
|
+
get_additional_props_func=get_additional_props_func
|
469
|
+
)
|
470
|
+
|
471
|
+
# Convert the markdown to HTML
|
472
|
+
return markdown_to_html(report_output)
|
473
|
+
|
386
474
|
elif output_format == 'DICT':
|
387
475
|
return generate_entity_dict(
|
388
476
|
elements=elements,
|