pyegeria 5.3.6.2.5__py3-none-any.whl → 5.3.6.4__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 +3 -0
- pyegeria/_client.py +10 -0
- pyegeria/commands/cat/{freddie_jupyter.py → dr_egeria_jupyter.py} +8 -16
- pyegeria/commands/cat/{freddie_md.py → dr_egeria_md.py} +39 -33
- pyegeria/commands/cat/glossary_actions.py +59 -1
- pyegeria/commands/cat/list_categories.py +185 -0
- pyegeria/commands/cat/list_glossaries.py +26 -33
- pyegeria/commands/cat/list_terms.py +47 -47
- pyegeria/commands/cli/egeria.py +51 -29
- pyegeria/commands/cli/egeria_cat.py +53 -31
- pyegeria/create_tech_guid_lists.py +2 -5
- pyegeria/glossary_browser_omvs.py +283 -113
- pyegeria/glossary_manager_omvs.py +150 -1594
- pyegeria/md_processing_utils.py +853 -0
- {pyegeria-5.3.6.2.5.dist-info → pyegeria-5.3.6.4.dist-info}/METADATA +1 -1
- {pyegeria-5.3.6.2.5.dist-info → pyegeria-5.3.6.4.dist-info}/RECORD +21 -31
- {pyegeria-5.3.6.2.5.dist-info → pyegeria-5.3.6.4.dist-info}/entry_points.txt +5 -0
- pyegeria/commands/cat/freddie_jup.py +0 -124
- pyegeria/commands/cat/freddie_utils.py +0 -590
- pyegeria/commands/cat/freddies-inbox/freddie_intro.md +0 -221
- pyegeria/commands/cat/freddies-outbox/Terms-2025-03-06-13-19-29-Report.md +0 -69
- pyegeria/commands/cat/freddies-outbox/Terms-2025-03-06-13-20-30-Update-Form.md +0 -78
- pyegeria/commands/cat/freddies-outbox/Terms-2025-03-06-19-39-25-Update-Form.md +0 -78
- pyegeria/commands/cat/glossary_creation_experiment.ipynb +0 -235
- pyegeria/test_j.html +0 -0
- pyegeria/test_m.html +0 -213
- pyegeria/test_m1.html +0 -273
- pyegeria/test_mer.ipynb +0 -596
- pyegeria/test_w.html +0 -213
- /pyegeria/commands/cat/{freddies-inbox → dr_egeria_inbox}/glossary_creation_experiment.ipynb +0 -0
- /pyegeria/commands/cat/{freddies-inbox → dr_egeria_inbox}/glossary_exp.md +0 -0
- {pyegeria-5.3.6.2.5.dist-info → pyegeria-5.3.6.4.dist-info}/LICENSE +0 -0
- {pyegeria-5.3.6.2.5.dist-info → pyegeria-5.3.6.4.dist-info}/WHEEL +0 -0
pyegeria/__init__.py
CHANGED
@@ -90,6 +90,9 @@ from .solution_architect_omvs import SolutionArchitect
|
|
90
90
|
from .utils import body_slimmer, print_response
|
91
91
|
from .valid_metadata_omvs import ValidMetadataManager
|
92
92
|
from .x_action_author_omvs import ActionAuthor
|
93
|
+
from .md_processing_utils import (extract_command, process_glossary_upsert_command, process_term_upsert_command,
|
94
|
+
process_categories_upsert_command,
|
95
|
+
get_current_datetime_string, process_per_proj_upsert_command, commands)
|
93
96
|
|
94
97
|
#
|
95
98
|
# 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")
|
@@ -1,28 +1,20 @@
|
|
1
1
|
"""
|
2
2
|
This is an ongoing experiment in parsing and playing with Freddie docs
|
3
3
|
"""
|
4
|
-
import json
|
5
4
|
|
6
|
-
from jupyter_notebook_parser import JupyterNotebookParser
|
7
5
|
import nbformat
|
8
6
|
import os
|
9
|
-
import
|
10
|
-
from pyegeria import EgeriaTech
|
11
|
-
from rich import box, print
|
7
|
+
from rich import print
|
12
8
|
from rich.console import Console
|
13
|
-
from
|
14
|
-
|
15
|
-
from rich.table import Table
|
16
|
-
from freddie_utils import (extract_command, process_glossary_upsert_command, process_term_upsert_command,
|
17
|
-
get_current_datetime_string, process_per_proj_upsert_command, commands)
|
9
|
+
from pyegeria.md_processing_utils import (extract_command, process_glossary_upsert_command, process_term_upsert_command,
|
10
|
+
get_current_datetime_string, process_per_proj_upsert_command, commands)
|
18
11
|
import click
|
19
|
-
from pyegeria import
|
12
|
+
from pyegeria import (extract_command, process_glossary_upsert_command, process_term_upsert_command,
|
13
|
+
get_current_datetime_string, process_per_proj_upsert_command, commands,EgeriaTech
|
14
|
+
)
|
20
15
|
from pyegeria._exceptions import (
|
21
|
-
InvalidParameterException,
|
22
|
-
PropertyServerException,
|
23
16
|
print_exception_response,
|
24
17
|
)
|
25
|
-
from datetime import datetime
|
26
18
|
|
27
19
|
EGERIA_METADATA_STORE = os.environ.get("EGERIA_METADATA_STORE", "active-metadata-store")
|
28
20
|
EGERIA_KAFKA_ENDPOINT = os.environ.get("KAFKA_ENDPOINT", "localhost:9092")
|
@@ -44,8 +36,8 @@ EGERIA_JUPYTER = os.environ.get("EGERIA_JUPYTER", False)
|
|
44
36
|
EGERIA_HOME_GLOSSARY_GUID = os.environ.get("EGERIA_HOME_GLOSSARY_GUID", None)
|
45
37
|
EGERIA_GLOSSARY_PATH = os.environ.get("EGERIA_GLOSSARY_PATH", None)
|
46
38
|
EGERIA_ROOT_PATH = os.environ.get("EGERIA_ROOT_PATH", "/Users/dwolfson/localGit/egeria-v5-3/egeria-python")
|
47
|
-
EGERIA_INBOX_PATH = os.environ.get("EGERIA_INBOX_PATH", "pyegeria/commands/cat/
|
48
|
-
EGERIA_OUTBOX_PATH = os.environ.get("EGERIA_OUTBOX_PATH", "pyegeria/commands/cat/
|
39
|
+
EGERIA_INBOX_PATH = os.environ.get("EGERIA_INBOX_PATH", "pyegeria/commands/cat/dr_egeria_inbox")
|
40
|
+
EGERIA_OUTBOX_PATH = os.environ.get("EGERIA_OUTBOX_PATH", "pyegeria/commands/cat/dr_egeria_outbox")
|
49
41
|
|
50
42
|
console = Console(width=int(EGERIA_WIDTH))
|
51
43
|
|
@@ -2,27 +2,20 @@
|
|
2
2
|
This is an ongoing experiment in parsing and playing with Freddie docs
|
3
3
|
"""
|
4
4
|
import json
|
5
|
-
import mistune
|
6
|
-
from jupyter_notebook_parser import JupyterNotebookParser
|
7
|
-
import nbformat
|
8
5
|
import os
|
9
|
-
import
|
10
|
-
from pyegeria import EgeriaTech
|
11
|
-
from rich import box, print
|
6
|
+
from rich import print
|
12
7
|
from rich.console import Console
|
13
8
|
from rich.markdown import Markdown
|
14
|
-
|
15
|
-
from
|
16
|
-
|
17
|
-
|
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)
|
18
13
|
|
19
14
|
import click
|
20
|
-
from pyegeria import
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
print_exception_response,
|
25
|
-
)
|
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
|
+
)
|
26
19
|
from datetime import datetime
|
27
20
|
|
28
21
|
EGERIA_METADATA_STORE = os.environ.get("EGERIA_METADATA_STORE", "active-metadata-store")
|
@@ -45,8 +38,8 @@ EGERIA_JUPYTER = os.environ.get("EGERIA_JUPYTER", False)
|
|
45
38
|
EGERIA_HOME_GLOSSARY_GUID = os.environ.get("EGERIA_HOME_GLOSSARY_GUID", None)
|
46
39
|
EGERIA_GLOSSARY_PATH = os.environ.get("EGERIA_GLOSSARY_PATH", None)
|
47
40
|
EGERIA_ROOT_PATH = os.environ.get("EGERIA_ROOT_PATH", "/Users/dwolfson/localGit/egeria-v5-3/egeria-python")
|
48
|
-
EGERIA_INBOX_PATH = os.environ.get("EGERIA_INBOX_PATH", "pyegeria/commands/cat/
|
49
|
-
EGERIA_OUTBOX_PATH = os.environ.get("EGERIA_OUTBOX_PATH", "pyegeria/commands/cat/
|
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")
|
50
43
|
|
51
44
|
console = Console(width=int(EGERIA_WIDTH))
|
52
45
|
|
@@ -84,8 +77,9 @@ def process_markdown_file(
|
|
84
77
|
print(f"Error: File not found at path: {full_file_path}")
|
85
78
|
return {} # Return empty dict if file not found
|
86
79
|
|
87
|
-
final_output =
|
88
|
-
|
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")
|
89
83
|
h1_blocks = []
|
90
84
|
current_block = ""
|
91
85
|
in_h1_block = False
|
@@ -111,15 +105,20 @@ def process_markdown_file(
|
|
111
105
|
|
112
106
|
if current_block: # Add the last H1 block
|
113
107
|
h1_blocks.append(current_block)
|
114
|
-
|
108
|
+
prov_found = False
|
115
109
|
# Process each identified H1 block
|
116
110
|
for block in h1_blocks:
|
117
111
|
potential_command = extract_command(block) # Extract potential command
|
118
112
|
|
119
113
|
if potential_command in commands:
|
120
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)
|
121
118
|
if potential_command in ["Create Glossary", "Update Glossary"]:
|
122
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)
|
123
122
|
elif potential_command in ["Create Term", "Update Term"]:
|
124
123
|
result = process_term_upsert_command(client, element_dictionary, block, directive)
|
125
124
|
elif potential_command in ["Create Personal Project", "Update Personal Project"]:
|
@@ -132,7 +131,7 @@ def process_markdown_file(
|
|
132
131
|
if directive == "process":
|
133
132
|
updated = True
|
134
133
|
final_output += f"\n---\n{result}\n---\n\n"
|
135
|
-
|
134
|
+
print(json.dumps(element_dictionary, indent=4))
|
136
135
|
elif directive == "process":
|
137
136
|
# Handle case with errors (skip this block but notify the user)
|
138
137
|
print(f"\n==>\tErrors found while processing command: \'{potential_command}\'\n"
|
@@ -142,19 +141,26 @@ def process_markdown_file(
|
|
142
141
|
# If no command is detected, add the block to the final output as-is
|
143
142
|
final_output += f"\n---\n{block}\n---\n\n"
|
144
143
|
|
144
|
+
|
145
145
|
# Write the final_output to a new file if updated
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
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.")
|
157
161
|
|
162
|
+
except (Exception):
|
163
|
+
console.print_exception(show_locals=True)
|
158
164
|
|
159
165
|
|
160
166
|
if __name__ == "__main__":
|
@@ -259,6 +259,64 @@ def delete_term(server, url, userid, password, timeout, term_guid):
|
|
259
259
|
finally:
|
260
260
|
m_client.close_session()
|
261
261
|
|
262
|
+
@click.command("add-term-to-category")
|
263
|
+
@click.option("--server", default=EGERIA_VIEW_SERVER, help="Egeria view server to use")
|
264
|
+
@click.option(
|
265
|
+
"--url", default=EGERIA_VIEW_SERVER_URL, help="URL of Egeria platform to connect to"
|
266
|
+
)
|
267
|
+
@click.option("--userid", default=EGERIA_USER, help="Egeria user")
|
268
|
+
@click.option("--password", default=EGERIA_USER_PASSWORD, help="Egeria user password")
|
269
|
+
@click.option("--timeout", default=60, help="Number of seconds to wait")
|
270
|
+
@click.option("--term-guid", required=True, help="GUID of term to add to a category")
|
271
|
+
@click.option("--category-guid", required=True, help="GUID of category to add term to")
|
272
|
+
|
273
|
+
def add_term_to_category(server, url, userid, password, timeout, term_guid, category_guid):
|
274
|
+
"""Add a glossary term to a category"""
|
275
|
+
m_client = EgeriaTech(server, url, user_id=userid, user_pwd=password)
|
276
|
+
token = m_client.create_egeria_bearer_token()
|
277
|
+
try:
|
278
|
+
term_guid = term_guid.strip()
|
279
|
+
category_guid = category_guid.strip()
|
280
|
+
m_client.add_term_to_category(term_guid, category_guid)
|
281
|
+
|
282
|
+
click.echo(
|
283
|
+
f"Added term with GUID: {term_guid} to category with GUID: {category_guid}\n"
|
284
|
+
)
|
285
|
+
|
286
|
+
except (InvalidParameterException, PropertyServerException) as e:
|
287
|
+
print_exception_response(e)
|
288
|
+
finally:
|
289
|
+
m_client.close_session()
|
290
|
+
|
291
|
+
@click.command("remove-term-from-category")
|
292
|
+
@click.option("--server", default=EGERIA_VIEW_SERVER, help="Egeria view server to use")
|
293
|
+
@click.option(
|
294
|
+
"--url", default=EGERIA_VIEW_SERVER_URL, help="URL of Egeria platform to connect to"
|
295
|
+
)
|
296
|
+
@click.option("--userid", default=EGERIA_USER, help="Egeria user")
|
297
|
+
@click.option("--password", default=EGERIA_USER_PASSWORD, help="Egeria user password")
|
298
|
+
@click.option("--timeout", default=60, help="Number of seconds to wait")
|
299
|
+
@click.option("--term-guid", required=True, help="GUID of term to add to a category")
|
300
|
+
@click.option("--category-guid", required=True, help="GUID of category to add term to")
|
301
|
+
|
302
|
+
def remove_term_from_category(server, url, userid, password, timeout, term_guid, category_guid):
|
303
|
+
"""Add a glossary term to a category"""
|
304
|
+
m_client = EgeriaTech(server, url, user_id=userid, user_pwd=password)
|
305
|
+
token = m_client.create_egeria_bearer_token()
|
306
|
+
try:
|
307
|
+
term_guid = term_guid.strip()
|
308
|
+
category_guid = category_guid.strip()
|
309
|
+
m_client.remove_term_from_category(term_guid, category_guid)
|
310
|
+
|
311
|
+
click.echo(
|
312
|
+
f"Removed term with GUID: {term_guid} from category with GUID: {category_guid}\n"
|
313
|
+
)
|
314
|
+
|
315
|
+
except (InvalidParameterException, PropertyServerException) as e:
|
316
|
+
print_exception_response(e)
|
317
|
+
finally:
|
318
|
+
m_client.close_session()
|
319
|
+
|
262
320
|
|
263
321
|
@click.command("import-terms-from-csv")
|
264
322
|
@click.option("--glossary_name", help="Name of Glossary", required=True)
|
@@ -368,7 +426,7 @@ def export_terms_csv(
|
|
368
426
|
@click.option(
|
369
427
|
"--is_root",
|
370
428
|
help="Is this a root category?",
|
371
|
-
default=
|
429
|
+
default=True,
|
372
430
|
is_flag=True,
|
373
431
|
)
|
374
432
|
@click.option("--server", default=EGERIA_VIEW_SERVER, help="Egeria view server to use.")
|
@@ -0,0 +1,185 @@
|
|
1
|
+
#!/usr/bin/env python3
|
2
|
+
"""
|
3
|
+
SPDX-License-Identifier: Apache-2.0
|
4
|
+
Copyright Contributors to the ODPi Egeria project.
|
5
|
+
|
6
|
+
List categories for a category.
|
7
|
+
|
8
|
+
|
9
|
+
A simple display for category terms
|
10
|
+
"""
|
11
|
+
import argparse
|
12
|
+
import os
|
13
|
+
import sys
|
14
|
+
import time
|
15
|
+
|
16
|
+
from rich import box
|
17
|
+
from rich.console import Console
|
18
|
+
from rich.prompt import Prompt
|
19
|
+
from rich.table import Table
|
20
|
+
from rich.text import Text
|
21
|
+
|
22
|
+
from pyegeria import (
|
23
|
+
EgeriaTech,
|
24
|
+
InvalidParameterException,
|
25
|
+
PropertyServerException,
|
26
|
+
UserNotAuthorizedException,
|
27
|
+
print_exception_response,
|
28
|
+
)
|
29
|
+
|
30
|
+
disable_ssl_warnings = True
|
31
|
+
|
32
|
+
EGERIA_METADATA_STORE = os.environ.get("EGERIA_METADATA_STORE", "active-metadata-store")
|
33
|
+
EGERIA_KAFKA_ENDPOINT = os.environ.get("KAFKA_ENDPOINT", "localhost:9092")
|
34
|
+
EGERIA_PLATFORM_URL = os.environ.get("EGERIA_PLATFORM_URL", "https://localhost:9443")
|
35
|
+
EGERIA_VIEW_SERVER = os.environ.get("EGERIA_VIEW_SERVER", "view-server")
|
36
|
+
EGERIA_VIEW_SERVER_URL = os.environ.get(
|
37
|
+
"EGERIA_VIEW_SERVER_URL", "https://localhost:9443"
|
38
|
+
)
|
39
|
+
EGERIA_INTEGRATION_DAEMON = os.environ.get("EGERIA_INTEGRATION_DAEMON", "integration-daemon")
|
40
|
+
EGERIA_ADMIN_USER = os.environ.get("ADMIN_USER", "garygeeke")
|
41
|
+
EGERIA_ADMIN_PASSWORD = os.environ.get("ADMIN_PASSWORD", "secret")
|
42
|
+
EGERIA_USER = os.environ.get("EGERIA_USER", "erinoverview")
|
43
|
+
EGERIA_USER_PASSWORD = os.environ.get("EGERIA_USER_PASSWORD", "secret")
|
44
|
+
EGERIA_JUPYTER = bool(os.environ.get("EGERIA_JUPYTER", "False"))
|
45
|
+
EGERIA_WIDTH = int(os.environ.get("EGERIA_WIDTH", "150"))
|
46
|
+
EGERIA_category_PATH = os.environ.get("EGERIA_category_PATH", None)
|
47
|
+
EGERIA_ROOT_PATH = os.environ.get("EGERIA_ROOT_PATH", "/Users/dwolfson/localGit/egeria-v5-3/egeria-python")
|
48
|
+
EGERIA_INBOX_PATH = os.environ.get("EGERIA_INBOX_PATH", "pyegeria/commands/cat/dr_egeria_inbox")
|
49
|
+
EGERIA_OUTBOX_PATH = os.environ.get("EGERIA_OUTBOX_PATH", "pyegeria/commands/cat/dr_egeria_outbox")
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
def display_categories(
|
54
|
+
search_string: str = "*",
|
55
|
+
view_server: str = EGERIA_VIEW_SERVER,
|
56
|
+
view_url: str = EGERIA_VIEW_SERVER_URL,
|
57
|
+
user: str = EGERIA_USER,
|
58
|
+
user_pass: str = EGERIA_USER_PASSWORD,
|
59
|
+
jupyter: bool = EGERIA_JUPYTER,
|
60
|
+
width: int = EGERIA_WIDTH,
|
61
|
+
output_format: str = "TABLE",
|
62
|
+
):
|
63
|
+
"""Display either a specified category or all categories if the search_string is '*'.
|
64
|
+
Parameters
|
65
|
+
----------
|
66
|
+
search_string : str, default is '*'
|
67
|
+
The string used to search for categories.
|
68
|
+
view_server : str
|
69
|
+
The view server name or address where the Egeria services are hosted.
|
70
|
+
view_url : str
|
71
|
+
The URL of the platform the view server is on.
|
72
|
+
user : str
|
73
|
+
The user ID for authentication with the Egeria server.
|
74
|
+
user_pass : str
|
75
|
+
The password for authentication with the Egeria server.
|
76
|
+
jupyter : bool, optional
|
77
|
+
A boolean indicating whether the output is intended for a Jupyter notebook (default is EGERIA_JUPYTER).
|
78
|
+
width : int, optional
|
79
|
+
The width of the console output (default is EGERIA_WIDTH).
|
80
|
+
output_format: str, optional, default is 'JSON'
|
81
|
+
One of FORM, REPORT, TABLE
|
82
|
+
"""
|
83
|
+
m_client = EgeriaTech(view_server, view_url, user_id=user, user_pwd=user_pass)
|
84
|
+
token = m_client.create_egeria_bearer_token()
|
85
|
+
|
86
|
+
|
87
|
+
try:
|
88
|
+
if output_format == "FORM":
|
89
|
+
action = "Update-Form"
|
90
|
+
elif output_format == "REPORT":
|
91
|
+
action = "Report"
|
92
|
+
if output_format != "TABLE":
|
93
|
+
file_path = os.path.join(EGERIA_ROOT_PATH, EGERIA_OUTBOX_PATH)
|
94
|
+
file_name = f"Categories-{time.strftime('%Y-%m-%d-%H-%M-%S')}-{action}.md"
|
95
|
+
full_file_path = os.path.join(file_path, file_name)
|
96
|
+
os.makedirs(os.path.dirname(full_file_path), exist_ok=True)
|
97
|
+
output = m_client.find_glossary_categories(search_string, output_format=output_format)
|
98
|
+
if output == "NO_CATEGORIES_FOUND":
|
99
|
+
print(f"\n==> No categories found for search string '{search_string}'")
|
100
|
+
return
|
101
|
+
with open(full_file_path, 'w') as f:
|
102
|
+
f.write(output)
|
103
|
+
print(f"\n==> Categories output written to {full_file_path}")
|
104
|
+
return
|
105
|
+
|
106
|
+
table = Table(
|
107
|
+
title=f"Category List @ {time.asctime()}",
|
108
|
+
style="bright_white on black",
|
109
|
+
header_style="bright_white on dark_blue",
|
110
|
+
title_style="bold white on black",
|
111
|
+
caption_style="white on black",
|
112
|
+
show_lines=True,
|
113
|
+
box=box.ROUNDED,
|
114
|
+
caption=f"View Server '{view_server}' @ Platform - {view_url}",
|
115
|
+
expand=True,
|
116
|
+
)
|
117
|
+
table.add_column("Category Name")
|
118
|
+
table.add_column(
|
119
|
+
"Qualified Name & GUID", width=38, no_wrap=True, justify="center"
|
120
|
+
)
|
121
|
+
table.add_column("Description")
|
122
|
+
table.add_column("In Glossary (Qualified Name)")
|
123
|
+
|
124
|
+
categories = m_client.find_glossary_categories(search_string)
|
125
|
+
if type(categories) is list:
|
126
|
+
sorted_category_list = sorted(
|
127
|
+
categories, key=lambda k: k["glossaryCategoryProperties"]["displayName"]
|
128
|
+
)
|
129
|
+
for category in sorted_category_list:
|
130
|
+
display_name = category["glossaryCategoryProperties"].get("displayName",'---')
|
131
|
+
qualified_name = category["glossaryCategoryProperties"]["qualifiedName"]
|
132
|
+
category_guid = category["elementHeader"]["guid"]
|
133
|
+
q_name = Text(f"{qualified_name}\n&\n{category_guid}", justify="center")
|
134
|
+
description = category["glossaryCategoryProperties"].get("description",'---')
|
135
|
+
classification_props = category["elementHeader"]['classifications'][0].get('classificationProperties',None)
|
136
|
+
glossary_qualified_name = '---'
|
137
|
+
if classification_props is not None:
|
138
|
+
glossary_guid = classification_props.get('anchorGUID','---')
|
139
|
+
glossary_qualified_name = (
|
140
|
+
m_client.get_glossary_by_guid(glossary_guid))['glossaryProperties']['qualifiedName']
|
141
|
+
|
142
|
+
table.add_row(display_name, q_name, description, glossary_qualified_name)
|
143
|
+
console = Console(
|
144
|
+
style="bold bright_white on black",
|
145
|
+
width=width,
|
146
|
+
force_terminal=not jupyter,
|
147
|
+
)
|
148
|
+
console.print(table)
|
149
|
+
|
150
|
+
except (InvalidParameterException, PropertyServerException) as e:
|
151
|
+
print_exception_response(e)
|
152
|
+
finally:
|
153
|
+
m_client.close_session()
|
154
|
+
|
155
|
+
|
156
|
+
def main():
|
157
|
+
parser = argparse.ArgumentParser()
|
158
|
+
parser.add_argument("--server", help="Name of the server to display status for")
|
159
|
+
parser.add_argument("--url", help="URL Platform to connect to")
|
160
|
+
parser.add_argument("--userid", help="User Id")
|
161
|
+
parser.add_argument("--password", help="User Password")
|
162
|
+
|
163
|
+
args = parser.parse_args()
|
164
|
+
|
165
|
+
server = args.server if args.server is not None else EGERIA_VIEW_SERVER
|
166
|
+
url = args.url if args.url is not None else EGERIA_PLATFORM_URL
|
167
|
+
userid = args.userid if args.userid is not None else EGERIA_USER
|
168
|
+
user_pass = args.password if args.password is not None else EGERIA_USER_PASSWORD
|
169
|
+
|
170
|
+
try:
|
171
|
+
search_string = Prompt.ask(
|
172
|
+
"Enter the category you are searching for or '*' for all:", default="*"
|
173
|
+
)
|
174
|
+
output_format = Prompt.ask("What output format do you want?", choices=["TABLE", "FORM", "REPORT"],
|
175
|
+
default="TABLE")
|
176
|
+
|
177
|
+
display_categories(search_string, server, url, userid,
|
178
|
+
user_pass, output_format = output_format)
|
179
|
+
|
180
|
+
except KeyboardInterrupt:
|
181
|
+
pass
|
182
|
+
|
183
|
+
|
184
|
+
if __name__ == "__main__":
|
185
|
+
main()
|
@@ -45,8 +45,8 @@ EGERIA_JUPYTER = bool(os.environ.get("EGERIA_JUPYTER", "False"))
|
|
45
45
|
EGERIA_WIDTH = int(os.environ.get("EGERIA_WIDTH", "200"))
|
46
46
|
EGERIA_GLOSSARY_PATH = os.environ.get("EGERIA_GLOSSARY_PATH", None)
|
47
47
|
EGERIA_ROOT_PATH = os.environ.get("EGERIA_ROOT_PATH", "/Users/dwolfson/localGit/egeria-v5-3/egeria-python")
|
48
|
-
EGERIA_INBOX_PATH = os.environ.get("EGERIA_INBOX_PATH", "pyegeria/commands/cat/
|
49
|
-
EGERIA_OUTBOX_PATH = os.environ.get("EGERIA_OUTBOX_PATH", "pyegeria/commands/cat/
|
48
|
+
EGERIA_INBOX_PATH = os.environ.get("EGERIA_INBOX_PATH", "pyegeria/commands/cat/dr_egeria_inbox")
|
49
|
+
EGERIA_OUTBOX_PATH = os.environ.get("EGERIA_OUTBOX_PATH", "pyegeria/commands/cat/dr_egeria_outbox")
|
50
50
|
|
51
51
|
|
52
52
|
|
@@ -58,8 +58,7 @@ def display_glossaries(
|
|
58
58
|
user_pass: str = EGERIA_USER_PASSWORD,
|
59
59
|
jupyter: bool = EGERIA_JUPYTER,
|
60
60
|
width: int = EGERIA_WIDTH,
|
61
|
-
|
62
|
-
form: bool = False,
|
61
|
+
output_format: str = "JSON"
|
63
62
|
):
|
64
63
|
"""Display either a specified glossary or all glossaries if the search_string is '*'.
|
65
64
|
Parameters
|
@@ -78,35 +77,38 @@ def display_glossaries(
|
|
78
77
|
A boolean indicating whether the output is intended for a Jupyter notebook (default is EGERIA_JUPYTER).
|
79
78
|
width : int, optional
|
80
79
|
The width of the console output (default is EGERIA_WIDTH).
|
81
|
-
|
82
|
-
|
83
|
-
The filepath is derived from the environment variables EGERIA_ROOT_PATH and EGERIA_OUTPUT_PATH, respectively.
|
84
|
-
form: bool, [default=False]
|
85
|
-
If true and md is true, a form for the glossaries will be created as a markdown file.
|
86
|
-
If false and md is true, a markdown report for the glossaries will be created.
|
80
|
+
output_format: str, optional, default is 'JSON'
|
81
|
+
One of TABLE, FORM, REPORT
|
87
82
|
"""
|
88
83
|
m_client = EgeriaTech(view_server, view_url, user_id=user, user_pwd=user_pass)
|
89
84
|
token = m_client.create_egeria_bearer_token()
|
90
|
-
|
85
|
+
console = Console(
|
86
|
+
style="bold bright_white on black",
|
87
|
+
width=width,
|
88
|
+
force_terminal=not jupyter,
|
89
|
+
)
|
91
90
|
|
92
91
|
try:
|
93
|
-
if
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
92
|
+
if output_format == "FORM":
|
93
|
+
action = "Update-Form"
|
94
|
+
elif output_format == "REPORT":
|
95
|
+
action = "Report"
|
96
|
+
if output_format != "TABLE":
|
98
97
|
file_path = os.path.join(EGERIA_ROOT_PATH, EGERIA_OUTBOX_PATH)
|
99
98
|
file_name = f"Glossaries-{time.strftime('%Y-%m-%d-%H-%M-%S')}-{action}.md"
|
100
99
|
full_file_path = os.path.join(file_path, file_name)
|
101
100
|
os.makedirs(os.path.dirname(full_file_path), exist_ok=True)
|
102
|
-
output = m_client.find_glossaries(search_string,
|
101
|
+
output = m_client.find_glossaries(search_string, None, output_format=output_format)
|
103
102
|
if output == "NO_GLOSSARIES_FOUND":
|
104
103
|
print(f"\n==> No glossaries found for search string '{search_string}'")
|
105
104
|
return
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
105
|
+
try:
|
106
|
+
with open(full_file_path, 'w') as f:
|
107
|
+
f.write(output)
|
108
|
+
print(f"\n==> Glossaries output written to {full_file_path}")
|
109
|
+
return
|
110
|
+
except Exception:
|
111
|
+
console.print_exception()
|
110
112
|
|
111
113
|
table = Table(
|
112
114
|
title=f"Glossary List @ {time.asctime()}",
|
@@ -141,11 +143,7 @@ def display_glossaries(
|
|
141
143
|
description = glossary["glossaryProperties"].get("description",'---')
|
142
144
|
usage = glossary["glossaryProperties"].get("usage",'---')
|
143
145
|
table.add_row(display_name, q_name, language, description, usage)
|
144
|
-
|
145
|
-
style="bold bright_white on black",
|
146
|
-
width=width,
|
147
|
-
force_terminal=not jupyter,
|
148
|
-
)
|
146
|
+
|
149
147
|
console.print(table)
|
150
148
|
|
151
149
|
except (InvalidParameterException, PropertyServerException) as e:
|
@@ -172,14 +170,9 @@ def main():
|
|
172
170
|
search_string = Prompt.ask(
|
173
171
|
"Enter the glossary you are searching for or '*' for all:", default="*"
|
174
172
|
)
|
175
|
-
|
176
|
-
md = True if mdq.lower() == "y" else False
|
177
|
-
|
178
|
-
formq = Prompt.ask("Do you want to create a form?", choices=["y", "n"], default="n")
|
179
|
-
form = True if formq.lower() == "y" else False
|
180
|
-
|
173
|
+
output_format = Prompt.ask("What output format do you want?", choices=["TABLE", "FORM", "REPORT"], default="TABLE")
|
181
174
|
display_glossaries(search_string, server, url, userid,
|
182
|
-
user_pass,
|
175
|
+
user_pass, output_format=output_format)
|
183
176
|
|
184
177
|
except KeyboardInterrupt:
|
185
178
|
pass
|