pyegeria 5.3.6.3__py3-none-any.whl → 5.3.6.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.
- pyegeria/__init__.py +2 -1
- pyegeria/_client.py +10 -0
- pyegeria/commands/cat/Dr-Egeria_md-orig.py +167 -0
- pyegeria/commands/cat/dr_egeria_md.py +53 -47
- pyegeria/commands/cat/get_collection.py +2 -2
- pyegeria/commands/cli/egeria.py +1 -1
- pyegeria/glossary_browser_omvs.py +49 -31
- pyegeria/glossary_manager_omvs.py +4 -5
- pyegeria/md_processing_utils.py +190 -123
- {pyegeria-5.3.6.3.dist-info → pyegeria-5.3.6.5.dist-info}/METADATA +1 -1
- {pyegeria-5.3.6.3.dist-info → pyegeria-5.3.6.5.dist-info}/RECORD +14 -14
- pyegeria/commands/cat/dr_egeria_inbox/freddie_intro.md +0 -269
- {pyegeria-5.3.6.3.dist-info → pyegeria-5.3.6.5.dist-info}/LICENSE +0 -0
- {pyegeria-5.3.6.3.dist-info → pyegeria-5.3.6.5.dist-info}/WHEEL +0 -0
- {pyegeria-5.3.6.3.dist-info → pyegeria-5.3.6.5.dist-info}/entry_points.txt +0 -0
pyegeria/__init__.py
CHANGED
@@ -92,7 +92,8 @@ from .valid_metadata_omvs import ValidMetadataManager
|
|
92
92
|
from .x_action_author_omvs import ActionAuthor
|
93
93
|
from .md_processing_utils import (extract_command, process_glossary_upsert_command, process_term_upsert_command,
|
94
94
|
process_categories_upsert_command,
|
95
|
-
get_current_datetime_string, process_per_proj_upsert_command, commands
|
95
|
+
get_current_datetime_string, process_per_proj_upsert_command, commands,
|
96
|
+
render_markdown, process_provenance_command)
|
96
97
|
|
97
98
|
#
|
98
99
|
# The following assignments were generated by the `create_tech_guid_lists.py` utility that uses the pyegeria functions
|
pyegeria/_client.py
CHANGED
@@ -11,6 +11,7 @@ import asyncio
|
|
11
11
|
import inspect
|
12
12
|
import json
|
13
13
|
import os
|
14
|
+
import re
|
14
15
|
from datetime import datetime
|
15
16
|
|
16
17
|
import httpx
|
@@ -769,6 +770,15 @@ class Client:
|
|
769
770
|
)
|
770
771
|
return result
|
771
772
|
|
773
|
+
def __create_qualified_name__(self, type: str, display_name: str, local_qualifier: str = None) -> str:
|
774
|
+
"""Helper function to create a qualified name for a given type and display name.
|
775
|
+
If present, the local qualifier will be prepended to the qualified name."""
|
776
|
+
EGERIA_LOCAL_QUALIFIER = os.environ.get("EGERIA_LOCAL_QUALIFIER", local_qualifier)
|
777
|
+
display_name = re.sub(r'\s','-',display_name.strip())
|
778
|
+
q_name = f"{type}:{display_name}"
|
779
|
+
if EGERIA_LOCAL_QUALIFIER:
|
780
|
+
q_name = f"{EGERIA_LOCAL_QUALIFIER}:{q_name}"
|
781
|
+
return q_name
|
772
782
|
|
773
783
|
if __name__ == "__main__":
|
774
784
|
print("Main-__client")
|
@@ -0,0 +1,167 @@
|
|
1
|
+
"""
|
2
|
+
This is an ongoing experiment in parsing and playing with Freddie docs
|
3
|
+
"""
|
4
|
+
import json
|
5
|
+
import os
|
6
|
+
from rich import print
|
7
|
+
from rich.console import Console
|
8
|
+
from rich.markdown import Markdown
|
9
|
+
|
10
|
+
from pyegeria.md_processing_utils import (extract_command, process_glossary_upsert_command, process_term_upsert_command,
|
11
|
+
get_current_datetime_string, process_per_proj_upsert_command, commands,
|
12
|
+
process_provenance_command)
|
13
|
+
|
14
|
+
import click
|
15
|
+
from pyegeria import (extract_command, process_glossary_upsert_command, process_term_upsert_command,
|
16
|
+
process_categories_upsert_command,
|
17
|
+
get_current_datetime_string, process_per_proj_upsert_command, commands,EgeriaTech
|
18
|
+
)
|
19
|
+
from datetime import datetime
|
20
|
+
|
21
|
+
EGERIA_METADATA_STORE = os.environ.get("EGERIA_METADATA_STORE", "active-metadata-store")
|
22
|
+
EGERIA_KAFKA_ENDPOINT = os.environ.get("KAFKA_ENDPOINT", "localhost:9092")
|
23
|
+
EGERIA_PLATFORM_URL = os.environ.get("EGERIA_PLATFORM_URL", "https://localhost:9443")
|
24
|
+
EGERIA_VIEW_SERVER = os.environ.get("EGERIA_VIEW_SERVER", "view-server")
|
25
|
+
EGERIA_VIEW_SERVER_URL = os.environ.get(
|
26
|
+
"EGERIA_VIEW_SERVER_URL", "https://localhost:9443"
|
27
|
+
)
|
28
|
+
EGERIA_INTEGRATION_DAEMON = os.environ.get("EGERIA_INTEGRATION_DAEMON", "integration-daemon")
|
29
|
+
EGERIA_INTEGRATION_DAEMON_URL = os.environ.get(
|
30
|
+
"EGERIA_INTEGRATION_DAEMON_URL", "https://localhost:9443"
|
31
|
+
)
|
32
|
+
EGERIA_ADMIN_USER = os.environ.get("ADMIN_USER", "garygeeke")
|
33
|
+
EGERIA_ADMIN_PASSWORD = os.environ.get("ADMIN_PASSWORD", "secret")
|
34
|
+
EGERIA_USER = os.environ.get("EGERIA_USER", "erinoverview")
|
35
|
+
EGERIA_USER_PASSWORD = os.environ.get("EGERIA_USER_PASSWORD", "secret")
|
36
|
+
EGERIA_WIDTH = os.environ.get("EGERIA_WIDTH", 220)
|
37
|
+
EGERIA_JUPYTER = os.environ.get("EGERIA_JUPYTER", False)
|
38
|
+
EGERIA_HOME_GLOSSARY_GUID = os.environ.get("EGERIA_HOME_GLOSSARY_GUID", None)
|
39
|
+
EGERIA_GLOSSARY_PATH = os.environ.get("EGERIA_GLOSSARY_PATH", None)
|
40
|
+
EGERIA_ROOT_PATH = os.environ.get("EGERIA_ROOT_PATH", "/Users/dwolfson/localGit/egeria-v5-3/egeria-python")
|
41
|
+
EGERIA_INBOX_PATH = os.environ.get("EGERIA_INBOX_PATH", "pyegeria/commands/cat/dr_egeria_inbox")
|
42
|
+
EGERIA_OUTBOX_PATH = os.environ.get("EGERIA_OUTBOX_PATH", "pyegeria/commands/cat/dr_egeria_outbox")
|
43
|
+
|
44
|
+
console = Console(width=int(EGERIA_WIDTH))
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
@click.command("process-markdown-file", help="Process a markdown file and return the output as a string.")
|
49
|
+
@click.option("--file-path", help="File path to markdown file",
|
50
|
+
default="glossary_exp.md")
|
51
|
+
@click.option("--directive", default="display-only", help="How to process the file")
|
52
|
+
@click.option("--server", default=EGERIA_VIEW_SERVER, help="Egeria view server to use.")
|
53
|
+
@click.option(
|
54
|
+
"--url", default=EGERIA_VIEW_SERVER_URL, help="URL of Egeria platform to connect to"
|
55
|
+
)
|
56
|
+
@click.option("--userid", default=EGERIA_USER, help="Egeria user")
|
57
|
+
@click.option("--user_pass", default=EGERIA_USER_PASSWORD, help="Egeria user password")
|
58
|
+
def process_markdown_file(
|
59
|
+
file_path: str,
|
60
|
+
directive: str,
|
61
|
+
server: str,
|
62
|
+
url: str,
|
63
|
+
userid: str,
|
64
|
+
user_pass: str,
|
65
|
+
):
|
66
|
+
|
67
|
+
client = EgeriaTech(server, url, user_id=userid)
|
68
|
+
token = client.create_egeria_bearer_token(userid, user_pass)
|
69
|
+
|
70
|
+
updated = False
|
71
|
+
full_file_path = os.path.join(EGERIA_ROOT_PATH, EGERIA_INBOX_PATH, file_path)
|
72
|
+
print(f"Processing Markdown File: {full_file_path}")
|
73
|
+
try:
|
74
|
+
with open(full_file_path, 'r') as f:
|
75
|
+
lines = f.readlines()
|
76
|
+
except FileNotFoundError:
|
77
|
+
print(f"Error: File not found at path: {full_file_path}")
|
78
|
+
return {} # Return empty dict if file not found
|
79
|
+
|
80
|
+
final_output =""
|
81
|
+
prov_output = (f"\n* Results from processing file {file_path} on "
|
82
|
+
f"{datetime.now().strftime("%Y-%m-%d %H:%M")}\n")
|
83
|
+
h1_blocks = []
|
84
|
+
current_block = ""
|
85
|
+
in_h1_block = False
|
86
|
+
element_dictionary = {}
|
87
|
+
|
88
|
+
for line in lines:
|
89
|
+
line = line.strip() # Remove leading/trailing whitespace
|
90
|
+
|
91
|
+
if line.startswith("# ") and not in_h1_block: # Start of a new H1 block
|
92
|
+
if current_block:
|
93
|
+
h1_blocks.append(current_block)
|
94
|
+
current_block = line
|
95
|
+
in_h1_block = True
|
96
|
+
elif line.startswith("---") and in_h1_block: # End of the current H1 block
|
97
|
+
h1_blocks.append(current_block)
|
98
|
+
current_block = ""
|
99
|
+
in_h1_block = False
|
100
|
+
elif in_h1_block: # Add line to the current H1 block
|
101
|
+
current_block += "\n" + line
|
102
|
+
else:
|
103
|
+
# Add non-H1 blocks directly to the final output
|
104
|
+
final_output += line
|
105
|
+
|
106
|
+
if current_block: # Add the last H1 block
|
107
|
+
h1_blocks.append(current_block)
|
108
|
+
prov_found = False
|
109
|
+
# Process each identified H1 block
|
110
|
+
for block in h1_blocks:
|
111
|
+
potential_command = extract_command(block) # Extract potential command
|
112
|
+
|
113
|
+
if potential_command in commands:
|
114
|
+
# Process the block based on the command
|
115
|
+
if potential_command == "Provenance":
|
116
|
+
prov_found = True
|
117
|
+
result = process_provenance_command(file_path, block)
|
118
|
+
elif potential_command in ["Create Glossary", "Update Glossary"]:
|
119
|
+
result = process_glossary_upsert_command(client, element_dictionary, block, directive)
|
120
|
+
elif potential_command in ["Create Category", "Update Category"]:
|
121
|
+
result = process_categories_upsert_command(client, element_dictionary, block, directive)
|
122
|
+
elif potential_command in ["Create Term", "Update Term"]:
|
123
|
+
result = process_term_upsert_command(client, element_dictionary, block, directive)
|
124
|
+
elif potential_command in ["Create Personal Project", "Update Personal Project"]:
|
125
|
+
result = process_per_proj_upsert_command(client, element_dictionary, block, directive)
|
126
|
+
else:
|
127
|
+
# If command is not recognized, copy the block as-is
|
128
|
+
result = None
|
129
|
+
|
130
|
+
if result:
|
131
|
+
if directive == "process":
|
132
|
+
updated = True
|
133
|
+
final_output += f"\n---\n{result}\n"
|
134
|
+
print(json.dumps(element_dictionary, indent=4))
|
135
|
+
elif directive == "process":
|
136
|
+
# Handle case with errors (skip this block but notify the user)
|
137
|
+
print(f"\n==>\tErrors found while processing command: \'{potential_command}\'\n"
|
138
|
+
f"\tPlease correct and try again. \n")
|
139
|
+
final_output += f"\n---\n{block}\n"
|
140
|
+
else:
|
141
|
+
# If no command is detected, add the block to the final output as-is
|
142
|
+
final_output += f"\n---\n{block}\n"
|
143
|
+
|
144
|
+
|
145
|
+
# Write the final_output to a new file if updated
|
146
|
+
try:
|
147
|
+
if updated:
|
148
|
+
path, filename = os.path.split(file_path) # Get both parts
|
149
|
+
new_filename = f"processed-{get_current_datetime_string()}-{filename}" # Create the new filename
|
150
|
+
new_file_path = os.path.join(EGERIA_ROOT_PATH, EGERIA_OUTBOX_PATH, new_filename) # Construct the new path
|
151
|
+
os.makedirs(os.path.dirname(new_file_path), exist_ok=True)
|
152
|
+
|
153
|
+
with open(new_file_path, 'w') as f2:
|
154
|
+
f2.write(final_output)
|
155
|
+
if not prov_found:
|
156
|
+
prov_output += f"\n# Provenance:\n{prov_output}\n"
|
157
|
+
f2.write(prov_output)
|
158
|
+
click.echo(f"\n==> Notebook written to {new_file_path}")
|
159
|
+
else:
|
160
|
+
click.echo("\nNo updates detected. New File not created.")
|
161
|
+
|
162
|
+
except (Exception):
|
163
|
+
console.print_exception(show_locals=True)
|
164
|
+
|
165
|
+
|
166
|
+
if __name__ == "__main__":
|
167
|
+
process_markdown_file()
|
@@ -8,7 +8,8 @@ from rich.console import Console
|
|
8
8
|
from rich.markdown import Markdown
|
9
9
|
|
10
10
|
from pyegeria.md_processing_utils import (extract_command, process_glossary_upsert_command, process_term_upsert_command,
|
11
|
-
get_current_datetime_string, process_per_proj_upsert_command, commands
|
11
|
+
get_current_datetime_string, process_per_proj_upsert_command, commands,
|
12
|
+
process_provenance_command)
|
12
13
|
|
13
14
|
import click
|
14
15
|
from pyegeria import (extract_command, process_glossary_upsert_command, process_term_upsert_command,
|
@@ -76,65 +77,65 @@ def process_markdown_file(
|
|
76
77
|
print(f"Error: File not found at path: {full_file_path}")
|
77
78
|
return {} # Return empty dict if file not found
|
78
79
|
|
79
|
-
final_output =
|
80
|
+
final_output =""
|
81
|
+
prov_found = False
|
82
|
+
prov_output = (f"\n* Results from processing file {file_path} on "
|
80
83
|
f"{datetime.now().strftime("%Y-%m-%d %H:%M")}\n")
|
81
84
|
h1_blocks = []
|
82
85
|
current_block = ""
|
83
86
|
in_h1_block = False
|
84
87
|
element_dictionary = {}
|
85
88
|
|
89
|
+
# Read and process lines sequentially, preserving their order
|
86
90
|
for line in lines:
|
87
91
|
line = line.strip() # Remove leading/trailing whitespace
|
88
92
|
|
89
|
-
if line.startswith("# ")
|
90
|
-
|
91
|
-
h1_blocks.append(current_block)
|
92
|
-
current_block = line
|
93
|
+
if line.startswith("# "): # Start of a new H1 block
|
94
|
+
current_block = line # Initialize the H1 block
|
93
95
|
in_h1_block = True
|
94
|
-
elif line
|
95
|
-
|
96
|
-
current_block
|
96
|
+
elif line.startswith("---") and in_h1_block: # End of the current H1 block
|
97
|
+
# Process the completed H1 block
|
98
|
+
current_block += f"\n{line}" # Add the closing line
|
99
|
+
potential_command = extract_command(current_block) # Extract command
|
100
|
+
|
101
|
+
if potential_command in commands:
|
102
|
+
# Process the block based on the command
|
103
|
+
if potential_command == "Provenance":
|
104
|
+
prov_found = True
|
105
|
+
result = process_provenance_command(file_path, current_block)
|
106
|
+
elif potential_command in ["Create Glossary", "Update Glossary"]:
|
107
|
+
result = process_glossary_upsert_command(client, element_dictionary, current_block, directive)
|
108
|
+
elif potential_command in ["Create Category", "Update Category"]:
|
109
|
+
result = process_categories_upsert_command(client, element_dictionary, current_block, directive)
|
110
|
+
elif potential_command in ["Create Term", "Update Term"]:
|
111
|
+
result = process_term_upsert_command(client, element_dictionary, current_block, directive)
|
112
|
+
elif potential_command in ["Create Personal Project", "Update Personal Project"]:
|
113
|
+
result = process_per_proj_upsert_command(client, element_dictionary, current_block, directive)
|
114
|
+
else:
|
115
|
+
# If command is not recognized, keep the block as-is
|
116
|
+
result = None
|
117
|
+
|
118
|
+
if result:
|
119
|
+
if directive == "process":
|
120
|
+
updated = True
|
121
|
+
final_output += f"\n---\n{result}\n"
|
122
|
+
print(json.dumps(element_dictionary, indent=4))
|
123
|
+
elif directive == "process":
|
124
|
+
# Handle errors (skip this block but notify the user)
|
125
|
+
print(f"\n==>\tErrors found while processing command: \'{potential_command}\'\n"
|
126
|
+
f"\tPlease correct and try again. \n")
|
127
|
+
final_output += f"\n---\n{current_block}\n"
|
128
|
+
else:
|
129
|
+
# If there is no command, append the block as-is
|
130
|
+
final_output += f"\n---\n{current_block}\n"
|
131
|
+
|
132
|
+
current_block = "" # Clear the block
|
97
133
|
in_h1_block = False
|
98
134
|
elif in_h1_block: # Add line to the current H1 block
|
99
|
-
current_block += "\n"
|
135
|
+
current_block += f"\n{line}"
|
100
136
|
else:
|
101
|
-
#
|
102
|
-
final_output += line
|
103
|
-
|
104
|
-
if current_block: # Add the last H1 block
|
105
|
-
h1_blocks.append(current_block)
|
106
|
-
|
107
|
-
# Process each identified H1 block
|
108
|
-
for block in h1_blocks:
|
109
|
-
potential_command = extract_command(block) # Extract potential command
|
110
|
-
|
111
|
-
if potential_command in commands:
|
112
|
-
# Process the block based on the command
|
113
|
-
if potential_command in ["Create Glossary", "Update Glossary"]:
|
114
|
-
result = process_glossary_upsert_command(client, element_dictionary, block, directive)
|
115
|
-
elif potential_command in ["Create Category", "Update Category"]:
|
116
|
-
result = process_categories_upsert_command(client, element_dictionary, block, directive)
|
117
|
-
elif potential_command in ["Create Term", "Update Term"]:
|
118
|
-
result = process_term_upsert_command(client, element_dictionary, block, directive)
|
119
|
-
elif potential_command in ["Create Personal Project", "Update Personal Project"]:
|
120
|
-
result = process_per_proj_upsert_command(client, element_dictionary, block, directive)
|
121
|
-
else:
|
122
|
-
# If command is not recognized, copy the block as-is
|
123
|
-
result = None
|
124
|
-
|
125
|
-
if result:
|
126
|
-
if directive == "process":
|
127
|
-
updated = True
|
128
|
-
final_output += f"\n---\n{Markdown(result)}\n---\n\n"
|
129
|
-
print(json.dumps(element_dictionary, indent=4))
|
130
|
-
elif directive == "process":
|
131
|
-
# Handle case with errors (skip this block but notify the user)
|
132
|
-
print(f"\n==>\tErrors found while processing command: \'{potential_command}\'\n"
|
133
|
-
f"\tPlease correct and try again. \n")
|
134
|
-
final_output += f"\n---\n{block}\n---\n\n"
|
135
|
-
else:
|
136
|
-
# If no command is detected, add the block to the final output as-is
|
137
|
-
final_output += f"\n---\n{block}\n---\n\n"
|
137
|
+
# For non-H1 lines, add them directly to the output
|
138
|
+
final_output += f"\n{line}"
|
138
139
|
|
139
140
|
# Write the final_output to a new file if updated
|
140
141
|
try:
|
@@ -146,6 +147,11 @@ def process_markdown_file(
|
|
146
147
|
|
147
148
|
with open(new_file_path, 'w') as f2:
|
148
149
|
f2.write(final_output)
|
150
|
+
prov_output = process_provenance_command(file_path, prov_output)
|
151
|
+
# if not prov_found:
|
152
|
+
# prov_output += f"\n# Provenance:\n{prov_output}\n"
|
153
|
+
|
154
|
+
f2.write(prov_output)
|
149
155
|
click.echo(f"\n==> Notebook written to {new_file_path}")
|
150
156
|
else:
|
151
157
|
click.echo("\nNo updates detected. New File not created.")
|
@@ -20,8 +20,8 @@ from pyegeria import (
|
|
20
20
|
CollectionManager,
|
21
21
|
InvalidParameterException,
|
22
22
|
PropertyServerException,
|
23
|
-
UserNotAuthorizedException,
|
24
|
-
)
|
23
|
+
UserNotAuthorizedException, NO_ELEMENTS_FOUND,
|
24
|
+
)
|
25
25
|
from pyegeria._exceptions import print_exception_response
|
26
26
|
|
27
27
|
disable_ssl_warnings = True
|
pyegeria/commands/cli/egeria.py
CHANGED
@@ -34,7 +34,7 @@ from pyegeria.commands.cat.glossary_actions import (
|
|
34
34
|
remove_term_from_category
|
35
35
|
)
|
36
36
|
from pyegeria.commands.cat.dr_egeria_jupyter import process_jupyter_notebook
|
37
|
-
from pyegeria.commands.cat.
|
37
|
+
from pyegeria.commands.cat.dr_egeria_md import process_markdown_file
|
38
38
|
|
39
39
|
from pyegeria.commands.cat.list_categories import display_categories
|
40
40
|
from pyegeria.commands.cat.list_assets import display_assets
|
@@ -75,7 +75,7 @@ class GlossaryBrowser(Client):
|
|
75
75
|
- A string or None indicating the action description for the elements,
|
76
76
|
depending on the output format.
|
77
77
|
"""
|
78
|
-
search_string = search_string if search_string else "All
|
78
|
+
search_string = search_string if search_string else "All Elements"
|
79
79
|
elements_action = "Update " + obj_type
|
80
80
|
if output_format == "FORM":
|
81
81
|
preamble = (f"\n# Update {obj_type} Form - created at {datetime.now().strftime('%Y-%m-%d %H:%M')}\n"
|
@@ -87,9 +87,22 @@ class GlossaryBrowser(Client):
|
|
87
87
|
f"\t{obj_type} found from the search string: `{search_string}`\n\n")
|
88
88
|
elements_action = None
|
89
89
|
return elements_md, elements_action
|
90
|
+
|
90
91
|
else:
|
91
92
|
return "\n", elements_action
|
92
93
|
|
94
|
+
def make_md_attribute(self, attribute_name: str, attribute_value: str, output_type: str) -> str | None:
|
95
|
+
output = ""
|
96
|
+
attribute_value = attribute_value.strip() if attribute_value else None
|
97
|
+
attribute_title = attribute_name.title() if attribute_name else None
|
98
|
+
if output_type in ["FORM", "MD"]:
|
99
|
+
output = f"## {attribute_title}\n{attribute_value}\n\n"
|
100
|
+
elif output_type == "REPORT":
|
101
|
+
if attribute_value:
|
102
|
+
output = f"## {attribute_title}\n{attribute_value}\n\n"
|
103
|
+
return output
|
104
|
+
|
105
|
+
|
93
106
|
def generate_glossaries_md(self, elements: list | dict, search_string: str, output_format: str = 'MD')-> str:
|
94
107
|
elements_md, elements_action = self.make_preamble(obj_type="Glossary", search_string=search_string,
|
95
108
|
output_format=output_format)
|
@@ -105,26 +118,26 @@ class GlossaryBrowser(Client):
|
|
105
118
|
usage = properties.get("usage", None)
|
106
119
|
qualified_name = properties.get("qualifiedName", None)
|
107
120
|
|
108
|
-
if output_format
|
121
|
+
if output_format in ['FORM','MD']:
|
109
122
|
elements_md += f"# {elements_action}\n\n"
|
110
123
|
elements_md += f"## Glossary Name \n\n{display_name}\n\n"
|
111
|
-
|
124
|
+
|
112
125
|
elif output_format == 'REPORT':
|
113
126
|
elements_md += f"# Glossary Name: {display_name}\n\n"
|
114
127
|
else:
|
115
128
|
elements_md += f"## Glossary Name \n\n{display_name}\n\n"
|
116
|
-
elements_md += "## Update Description\n\n\n"
|
117
129
|
|
118
|
-
elements_md +=
|
119
|
-
elements_md +=
|
120
|
-
elements_md +=
|
121
|
-
elements_md +=
|
122
|
-
elements_md +=
|
123
|
-
elements_md += MD_SEPERATOR
|
130
|
+
elements_md += self.make_md_attribute( "description", description, output_format)
|
131
|
+
elements_md += self.make_md_attribute("language", language, output_format)
|
132
|
+
elements_md += self.make_md_attribute("usage", usage, output_format)
|
133
|
+
elements_md += self.make_md_attribute("qualified name", qualified_name, output_format)
|
134
|
+
elements_md += self.make_md_attribute("GUID", guid, output_format)
|
135
|
+
# elements_md += MD_SEPERATOR
|
136
|
+
|
124
137
|
return elements_md
|
125
138
|
|
126
139
|
def generate_terms_md(self, elements: list | dict, search_string: str, output_format: str = 'MD') -> str:
|
127
|
-
elements_md, elements_action = self.make_preamble(obj_type="
|
140
|
+
elements_md, elements_action = self.make_preamble(obj_type="Term", search_string=search_string, output_format=output_format)
|
128
141
|
if isinstance(elements, dict):
|
129
142
|
elements = [elements]
|
130
143
|
|
@@ -140,34 +153,38 @@ class GlossaryBrowser(Client):
|
|
140
153
|
qualified_name = element_properties.get("qualifiedName", None)
|
141
154
|
status = element['elementHeader'].get('status', None)
|
142
155
|
|
156
|
+
glossary_guid = element['elementHeader'].get('classifications', [{}])[0].get('classificationProperties', {}).get('anchorGUID', None)
|
157
|
+
glossary_qualified_name = self.get_glossary_by_guid(glossary_guid)['glossaryProperties']['qualifiedName']
|
158
|
+
|
143
159
|
category_list_md = "\n"
|
144
160
|
category_list = self.get_categories_for_term(guid)
|
145
161
|
if type(category_list) is str and category_list == NO_CATEGORIES_FOUND:
|
146
162
|
category_list_md = ['---']
|
147
163
|
elif isinstance(category_list, list) and len(category_list) > 0:
|
148
164
|
for category in category_list:
|
149
|
-
category_name = category["glossaryCategoryProperties"].get("
|
165
|
+
category_name = category["glossaryCategoryProperties"].get("qualifiedName", '---')
|
150
166
|
category_list_md += f" {category_name}\n"
|
151
167
|
|
152
|
-
if output_format
|
168
|
+
if output_format in ['FORM', 'MD']:
|
153
169
|
elements_md += f"# {elements_action}\n\n"
|
154
170
|
elements_md += f"## Term Name \n\n{display_name}\n\n"
|
155
|
-
elements_md += "## Update Description\n\n\n"
|
156
171
|
elif output_format == 'REPORT':
|
157
172
|
elements_md += f"# Term Name: {display_name}\n\n"
|
158
173
|
else:
|
159
174
|
elements_md += f"## Term Name \n\n{display_name}\n\n"
|
160
|
-
|
161
|
-
elements_md +=
|
162
|
-
elements_md +=
|
163
|
-
elements_md +=
|
164
|
-
elements_md +=
|
165
|
-
elements_md +=
|
166
|
-
elements_md +=
|
167
|
-
elements_md +=
|
168
|
-
elements_md +=
|
169
|
-
elements_md +=
|
175
|
+
|
176
|
+
elements_md += self.make_md_attribute("summary", summary, output_format)
|
177
|
+
elements_md += self.make_md_attribute("in glossary", glossary_qualified_name, output_format)
|
178
|
+
elements_md += self.make_md_attribute( "categories", category_list_md, output_format)
|
179
|
+
elements_md += self.make_md_attribute( "status", status, output_format)
|
180
|
+
elements_md += self.make_md_attribute( "description", description, output_format)
|
181
|
+
elements_md += self.make_md_attribute( "examples", examples, output_format)
|
182
|
+
elements_md += self.make_md_attribute("usage", usage, output_format)
|
183
|
+
elements_md += self.make_md_attribute("published version", pub_version, output_format)
|
184
|
+
elements_md += self.make_md_attribute("qualified name", qualified_name, output_format)
|
185
|
+
elements_md += self.make_md_attribute("GUID", guid, output_format)
|
170
186
|
elements_md += MD_SEPERATOR
|
187
|
+
|
171
188
|
return elements_md
|
172
189
|
|
173
190
|
def generate_categories_md(self, elements: list | dict, search_string: str, output_format: str = 'MD')-> str:
|
@@ -190,21 +207,22 @@ class GlossaryBrowser(Client):
|
|
190
207
|
glossary_qualified_name = (
|
191
208
|
self.get_glossary_by_guid(glossary_guid))['glossaryProperties']['qualifiedName']
|
192
209
|
|
193
|
-
if output_format
|
210
|
+
if output_format in ['FORM', 'MD']:
|
194
211
|
elements_md += f"# {elements_action}\n\n"
|
195
212
|
elements_md += f"## Category Name \n\n{display_name}\n\n"
|
196
|
-
|
213
|
+
|
197
214
|
elif output_format == 'REPORT':
|
198
215
|
elements_md += f"# Category Name: {display_name}\n\n"
|
199
216
|
else:
|
200
217
|
elements_md += f"## Category Name \n\n{display_name}\n\n"
|
201
|
-
elements_md += "## Update Description\n\n\n"
|
202
218
|
|
203
|
-
|
204
|
-
elements_md +=
|
205
|
-
elements_md +=
|
206
|
-
elements_md +=
|
219
|
+
|
220
|
+
elements_md += self.make_md_attribute("description", description, output_format)
|
221
|
+
elements_md += self.make_md_attribute("in glossary", glossary_qualified_name, output_format)
|
222
|
+
elements_md += self.make_md_attribute("qualified name", qualified_name, output_format)
|
223
|
+
elements_md += self.make_md_attribute("GUID", guid, output_format)
|
207
224
|
elements_md += MD_SEPERATOR
|
225
|
+
|
208
226
|
return elements_md
|
209
227
|
|
210
228
|
#
|
@@ -100,7 +100,7 @@ class GlossaryManager(GlossaryBrowser):
|
|
100
100
|
"class": "ReferenceableRequestBody",
|
101
101
|
"elementProperties": {
|
102
102
|
"class": "GlossaryProperties",
|
103
|
-
"qualifiedName":
|
103
|
+
"qualifiedName": self.__create_qualified_name__("Glossary", display_name),
|
104
104
|
"displayName": display_name,
|
105
105
|
"description": description,
|
106
106
|
"language": language,
|
@@ -351,7 +351,7 @@ class GlossaryManager(GlossaryBrowser):
|
|
351
351
|
"class": "ReferenceableRequestBody",
|
352
352
|
"elementProperties": {
|
353
353
|
"class": "GlossaryCategoryProperties",
|
354
|
-
"qualifiedName":
|
354
|
+
"qualifiedName": self.__create_qualified_name__("Category", display_name),
|
355
355
|
"displayName": display_name,
|
356
356
|
"description": description,
|
357
357
|
},
|
@@ -936,9 +936,8 @@ class GlossaryManager(GlossaryBrowser):
|
|
936
936
|
continue
|
937
937
|
|
938
938
|
# Add the term
|
939
|
-
term_qualified_name = (
|
940
|
-
|
941
|
-
)
|
939
|
+
term_qualified_name = self.__create_qualified_name("Term", display_name),
|
940
|
+
|
942
941
|
body = {
|
943
942
|
"class": "ReferenceableRequestBody",
|
944
943
|
"elementProperties": {
|