pyegeria 5.3.6.2.4__py3-none-any.whl → 5.3.6.3__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.
Files changed (31) hide show
  1. pyegeria/__init__.py +3 -0
  2. pyegeria/commands/cat/{freddies-inbox → dr_egeria_inbox}/freddie_intro.md +64 -16
  3. pyegeria/commands/cat/{freddie_jupyter.py → dr_egeria_jupyter.py} +8 -16
  4. pyegeria/commands/cat/{freddie_md.py → dr_egeria_md.py} +29 -32
  5. pyegeria/commands/cat/glossary_actions.py +59 -1
  6. pyegeria/commands/cat/list_categories.py +185 -0
  7. pyegeria/commands/cat/list_glossaries.py +26 -33
  8. pyegeria/commands/cat/list_terms.py +47 -47
  9. pyegeria/commands/cli/egeria.py +51 -61
  10. pyegeria/commands/cli/egeria_cat.py +53 -31
  11. pyegeria/create_tech_guid_lists.py +2 -5
  12. pyegeria/glossary_browser_omvs.py +257 -105
  13. pyegeria/glossary_manager_omvs.py +148 -1591
  14. pyegeria/md_processing_utils.py +816 -0
  15. {pyegeria-5.3.6.2.4.dist-info → pyegeria-5.3.6.3.dist-info}/METADATA +1 -1
  16. {pyegeria-5.3.6.2.4.dist-info → pyegeria-5.3.6.3.dist-info}/RECORD +21 -29
  17. {pyegeria-5.3.6.2.4.dist-info → pyegeria-5.3.6.3.dist-info}/entry_points.txt +5 -0
  18. pyegeria/commands/cat/freddie_jup.py +0 -124
  19. pyegeria/commands/cat/freddie_utils.py +0 -590
  20. pyegeria/commands/cat/freddies-outbox/Terms-2025-03-06-13-19-29-Report.md +0 -69
  21. pyegeria/commands/cat/freddies-outbox/Terms-2025-03-06-13-20-30-Update-Form.md +0 -78
  22. pyegeria/commands/cat/glossary_creation_experiment.ipynb +0 -235
  23. pyegeria/test_j.html +0 -0
  24. pyegeria/test_m.html +0 -213
  25. pyegeria/test_m1.html +0 -273
  26. pyegeria/test_mer.ipynb +0 -596
  27. pyegeria/test_w.html +0 -213
  28. /pyegeria/commands/cat/{freddies-inbox → dr_egeria_inbox}/glossary_creation_experiment.ipynb +0 -0
  29. /pyegeria/commands/cat/{freddies-inbox → dr_egeria_inbox}/glossary_exp.md +0 -0
  30. {pyegeria-5.3.6.2.4.dist-info → pyegeria-5.3.6.3.dist-info}/LICENSE +0 -0
  31. {pyegeria-5.3.6.2.4.dist-info → pyegeria-5.3.6.3.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
@@ -1,12 +1,14 @@
1
+
1
2
  # Introduction to Freddie - an Egeria Markdown Processor
2
3
 
4
+
3
5
  A constant challenge in managing information is gathering enough metadata about the information to
4
6
  allow us to manage it. A common approach is to build fancy graphical user interfaces hoping that they
5
7
  will be attractive enough and easy enough to use that people will do so.
6
8
 
7
9
  Unfortunately, however, this ignores the fundamental fact that to use one of these nice GUI
8
10
  applications, you have to step away from the tools and processes that you were in the midst of performing.
9
- You have to leave your world and join someone elses.
11
+ You have to leave your world and enter a new, often less familiar one.
10
12
 
11
13
  Freddie, is an experiment in turning this around. Its not that fancy graphical user
12
14
  interfaces don't have a role - but rather, to look at what we can do to support the
@@ -26,7 +28,7 @@ In the example below we will create a new Egeria glossary to hold definitions re
26
28
 
27
29
  ## Glossary Name
28
30
 
29
- Egeria-Markdown
31
+ test
30
32
 
31
33
  ## Language
32
34
 
@@ -42,13 +44,7 @@ commands, validates the Egeria content and allows the requests to be sent to Ege
42
44
 
43
45
  ## Usage
44
46
 
45
- 1. (optional) load an example or template for the type of object from Egeria.
46
- 2. Create a new document (perhaps from the template) and edit it, adding in the content with the Freddie controlled
47
- Markdown language.
48
- 3. Process the document to validate and display it before you submit it, Validation may annotate your document with
49
- recommendations and potential issues.
50
- 4. Submit the document to Egeria using the Freddie_sings command.
51
-
47
+ a quick test glossary
52
48
  ## <Qualified Name>
53
49
 
54
50
  ## <GUID>
@@ -85,15 +81,60 @@ We now have a nice, clean, new...and empty...glossary - guess we better start fi
85
81
 
86
82
  ---
87
83
 
84
+ # Create Category
85
+
86
+ ## Category Name
87
+
88
+ cat1
89
+
90
+ ## Owning Glossary
91
+
92
+ test
93
+
94
+ ## Description
95
+
96
+ These terms describe features of writing markdown files that can use Egeria-Markdown
97
+
98
+
99
+ ## <Qualified Name>
100
+
101
+ ## <GUID>
102
+
103
+ ---
104
+
105
+ # Create Category
106
+
107
+ ## Category Name
108
+
109
+ cat2
110
+
111
+ ## Owning Glossary
112
+
113
+ test
114
+
115
+ ## Description
116
+
117
+ These terms describe concepts related to processing Egeria-Markdown
118
+
119
+
120
+ ## <Qualified Name>
121
+
122
+ ## <GUID>
123
+ ---
124
+
88
125
  # Create Term
89
126
 
90
127
  ## Glossary Name
91
128
 
92
- Egeria-Markdown
129
+ test
93
130
 
94
131
  ## Term Name
95
132
 
96
- Command
133
+ t1
134
+
135
+ ## Categories
136
+
137
+ cat1, cat2
97
138
 
98
139
  ## Summary
99
140
 
@@ -120,11 +161,10 @@ Commands are used in the Freddie Egeria markdown language.
120
161
 
121
162
  ## Version
122
163
 
123
- 0.2
164
+ v1
124
165
 
125
166
  ## Status
126
167
 
127
- DRAFT
128
168
 
129
169
  ## Qualified Name
130
170
 
@@ -134,11 +174,16 @@ DRAFT
134
174
 
135
175
  ## Glossary Name
136
176
 
137
- Egeria-Markdown
177
+ test
138
178
 
139
179
  ## Term Name
140
180
 
141
- Source
181
+ t2
182
+
183
+ ## Categories
184
+ Writing Markdown
185
+
186
+ Processing Markdown
142
187
 
143
188
  ## Summary
144
189
 
@@ -162,7 +207,6 @@ Source of the markdown content - could be jupter or plain markdown file.
162
207
 
163
208
  DRAFT
164
209
 
165
- ## Update Description
166
210
 
167
211
  ---
168
212
 
@@ -176,6 +220,10 @@ Egeria-Markdown
176
220
 
177
221
  Directive
178
222
 
223
+ ## Categories
224
+
225
+ meow mix
226
+
179
227
  ## Summary
180
228
 
181
229
  A directive defines how the command is to be processed.
@@ -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 re
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 rich.markdown import Markdown
14
- from rich.prompt import Prompt
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 EgeriaTech, body_slimmer, NO_GLOSSARIES_FOUND, NO_TERMS_FOUND, NO_ELEMENTS_FOUND, NO_PROJECTS_FOUND
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/freddies-inbox")
48
- EGERIA_OUTBOX_PATH = os.environ.get("EGERIA_OUTBOX_PATH", "pyegeria/commands/cat/freddies-outbox")
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,19 @@
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 re
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
- from rich.prompt import Prompt
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
+
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)
18
12
 
19
13
  import click
20
- from pyegeria import EgeriaTech, body_slimmer, NO_GLOSSARIES_FOUND, NO_TERMS_FOUND, NO_ELEMENTS_FOUND, NO_PROJECTS_FOUND
21
- from pyegeria._exceptions import (
22
- InvalidParameterException,
23
- PropertyServerException,
24
- print_exception_response,
25
- )
14
+ from pyegeria import (extract_command, process_glossary_upsert_command, process_term_upsert_command,
15
+ process_categories_upsert_command,
16
+ get_current_datetime_string, process_per_proj_upsert_command, commands,EgeriaTech
17
+ )
26
18
  from datetime import datetime
27
19
 
28
20
  EGERIA_METADATA_STORE = os.environ.get("EGERIA_METADATA_STORE", "active-metadata-store")
@@ -45,8 +37,8 @@ EGERIA_JUPYTER = os.environ.get("EGERIA_JUPYTER", False)
45
37
  EGERIA_HOME_GLOSSARY_GUID = os.environ.get("EGERIA_HOME_GLOSSARY_GUID", None)
46
38
  EGERIA_GLOSSARY_PATH = os.environ.get("EGERIA_GLOSSARY_PATH", None)
47
39
  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/freddies-inbox")
49
- EGERIA_OUTBOX_PATH = os.environ.get("EGERIA_OUTBOX_PATH", "pyegeria/commands/cat/freddies-outbox")
40
+ EGERIA_INBOX_PATH = os.environ.get("EGERIA_INBOX_PATH", "pyegeria/commands/cat/dr_egeria_inbox")
41
+ EGERIA_OUTBOX_PATH = os.environ.get("EGERIA_OUTBOX_PATH", "pyegeria/commands/cat/dr_egeria_outbox")
50
42
 
51
43
  console = Console(width=int(EGERIA_WIDTH))
52
44
 
@@ -85,7 +77,7 @@ def process_markdown_file(
85
77
  return {} # Return empty dict if file not found
86
78
 
87
79
  final_output = (f"\n# Results from processing file {file_path} on "
88
- f"{datetime.now().strftime("%Y-%m-%d %H:%M")}\n---\n")
80
+ f"{datetime.now().strftime("%Y-%m-%d %H:%M")}\n")
89
81
  h1_blocks = []
90
82
  current_block = ""
91
83
  in_h1_block = False
@@ -120,6 +112,8 @@ def process_markdown_file(
120
112
  # Process the block based on the command
121
113
  if potential_command in ["Create Glossary", "Update Glossary"]:
122
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)
123
117
  elif potential_command in ["Create Term", "Update Term"]:
124
118
  result = process_term_upsert_command(client, element_dictionary, block, directive)
125
119
  elif potential_command in ["Create Personal Project", "Update Personal Project"]:
@@ -131,8 +125,8 @@ def process_markdown_file(
131
125
  if result:
132
126
  if directive == "process":
133
127
  updated = True
134
- final_output += f"\n---\n{result}\n---\n\n"
135
- # print(json.dumps(element_dictionary, indent=4))
128
+ final_output += f"\n---\n{Markdown(result)}\n---\n\n"
129
+ print(json.dumps(element_dictionary, indent=4))
136
130
  elif directive == "process":
137
131
  # Handle case with errors (skip this block but notify the user)
138
132
  print(f"\n==>\tErrors found while processing command: \'{potential_command}\'\n"
@@ -143,18 +137,21 @@ def process_markdown_file(
143
137
  final_output += f"\n---\n{block}\n---\n\n"
144
138
 
145
139
  # Write the final_output to a new file if updated
146
- if updated:
147
- path, filename = os.path.split(file_path) # Get both parts
148
- new_filename = f"processed-{get_current_datetime_string()}-{filename}" # Create the new filename
149
- new_file_path = os.path.join(EGERIA_ROOT_PATH, EGERIA_OUTBOX_PATH, new_filename) # Construct the new path
150
- os.makedirs(os.path.dirname(new_file_path), exist_ok=True)
151
-
152
- with open(new_file_path, 'w') as f2:
153
- f2.write(final_output)
154
- click.echo(f"\n==> Notebook written to {new_file_path}")
155
- else:
156
- click.echo("\nNo updates detected. New File not created.")
140
+ try:
141
+ if updated:
142
+ path, filename = os.path.split(file_path) # Get both parts
143
+ new_filename = f"processed-{get_current_datetime_string()}-{filename}" # Create the new filename
144
+ new_file_path = os.path.join(EGERIA_ROOT_PATH, EGERIA_OUTBOX_PATH, new_filename) # Construct the new path
145
+ os.makedirs(os.path.dirname(new_file_path), exist_ok=True)
146
+
147
+ with open(new_file_path, 'w') as f2:
148
+ f2.write(final_output)
149
+ click.echo(f"\n==> Notebook written to {new_file_path}")
150
+ else:
151
+ click.echo("\nNo updates detected. New File not created.")
157
152
 
153
+ except (Exception):
154
+ console.print_exception(show_locals=True)
158
155
 
159
156
 
160
157
  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=False,
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()