pyegeria 5.3.6.4__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 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
@@ -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()
@@ -78,6 +78,7 @@ def process_markdown_file(
78
78
  return {} # Return empty dict if file not found
79
79
 
80
80
  final_output =""
81
+ prov_found = False
81
82
  prov_output = (f"\n* Results from processing file {file_path} on "
82
83
  f"{datetime.now().strftime("%Y-%m-%d %H:%M")}\n")
83
84
  h1_blocks = []
@@ -85,62 +86,56 @@ def process_markdown_file(
85
86
  in_h1_block = False
86
87
  element_dictionary = {}
87
88
 
89
+ # Read and process lines sequentially, preserving their order
88
90
  for line in lines:
89
91
  line = line.strip() # Remove leading/trailing whitespace
90
92
 
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
93
+ if line.startswith("# "): # Start of a new H1 block
94
+ current_block = line # Initialize the H1 block
95
95
  in_h1_block = True
96
- elif line == "---" and in_h1_block: # End of the current H1 block
97
- h1_blocks.append(current_block)
98
- 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
99
133
  in_h1_block = False
100
134
  elif in_h1_block: # Add line to the current H1 block
101
- current_block += "\n" + line
135
+ current_block += f"\n{line}"
102
136
  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
- if 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---\n\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---\n\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---\n\n"
143
-
137
+ # For non-H1 lines, add them directly to the output
138
+ final_output += f"\n{line}"
144
139
 
145
140
  # Write the final_output to a new file if updated
146
141
  try:
@@ -152,8 +147,10 @@ def process_markdown_file(
152
147
 
153
148
  with open(new_file_path, 'w') as f2:
154
149
  f2.write(final_output)
155
- if not prov_found:
156
- prov_output += f"\n# Provenance:\n{prov_output}\n"
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
+
157
154
  f2.write(prov_output)
158
155
  click.echo(f"\n==> Notebook written to {new_file_path}")
159
156
  else:
@@ -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
@@ -183,7 +183,7 @@ class GlossaryBrowser(Client):
183
183
  elements_md += self.make_md_attribute("published version", pub_version, output_format)
184
184
  elements_md += self.make_md_attribute("qualified name", qualified_name, output_format)
185
185
  elements_md += self.make_md_attribute("GUID", guid, output_format)
186
- # elements_md += MD_SEPERATOR
186
+ elements_md += MD_SEPERATOR
187
187
 
188
188
  return elements_md
189
189
 
@@ -21,9 +21,9 @@ from rich.table import Table
21
21
  import click
22
22
  from pyegeria import EgeriaTech, body_slimmer, NO_GLOSSARIES_FOUND, NO_TERMS_FOUND, NO_ELEMENTS_FOUND, NO_PROJECTS_FOUND
23
23
  from pyegeria._exceptions import (InvalidParameterException, PropertyServerException, print_exception_response, )
24
- import datetime
25
-
26
- console = Console(width=120)
24
+ from datetime import datetime
25
+ EGERIA_WIDTH = int(os.environ.get("EGERIA_WIDTH", "200"))
26
+ console = Console(width=EGERIA_WIDTH)
27
27
 
28
28
  commands = ["Provenance", "Create Glossary", "Update Glossary", "Create Term", "Update Term", "Create Personal Project",
29
29
  "Update Personal Project", "Create Category", "Update Category"]
@@ -34,6 +34,10 @@ pre_command = "\n---\n==> Processing command:"
34
34
  EGERIA_LOCAL_QUALIFIER = os.environ.get("EGERIA_LOCAL_QUALIFIER", "PDR")
35
35
  element_dictionary = {}
36
36
 
37
+ def render_markdown(markdown_text: str) -> None:
38
+ """Renders the given markdown text in the console."""
39
+ console.print(Markdown(markdown_text))
40
+
37
41
 
38
42
  def is_valid_iso_date(date_text) -> bool:
39
43
  """Checks if the given string is a valid ISO date."""
@@ -46,10 +50,12 @@ def is_valid_iso_date(date_text) -> bool:
46
50
 
47
51
  def get_current_datetime_string():
48
52
  """Returns the current date and time as a human-readable string."""
49
- now = datetime.datetime.now()
50
- return now.strftime("%Y-%m-%d-%H-%M")
53
+ now = datetime.now().strftime('%Y-%m-%d %H:%M')
54
+ return now
55
+
51
56
 
52
- def add_term_to_categories(egeria_client: EgeriaTech, term_guid: str, categories_exist: bool, categories_list: [str], element_dictionary: dict)-> None:
57
+ def add_term_to_categories(egeria_client: EgeriaTech, term_guid: str, categories_exist: bool,
58
+ categories_list: List[str], element_dictionary: dict) -> None:
53
59
  if categories_exist is True and categories_list is not None:
54
60
  for category in categories_list:
55
61
  cat_guid = None
@@ -58,19 +64,18 @@ def add_term_to_categories(egeria_client: EgeriaTech, term_guid: str, categories
58
64
  cat= element_dictionary.get(cat_el, None)
59
65
  cat_guid = cat.get('guid', None) if cat else None
60
66
  if cat_guid is None:
61
- cat_guid = egeria_client.__get_guid__(qualified_name=category)
67
+ cat_guid = egeria_client.__get_guid__(qualified_name=cat_el)
62
68
  egeria_client.add_term_to_category(term_guid, cat_guid)
63
69
 
64
70
 
65
-
66
- def extract_command(block: str) -> str | None:
71
+ def extract_command(block: str) -> Optional[str]:
67
72
  match = re.search(r"#(.*?)(?:##|\n|$)", block) # Using a non capturing group
68
73
  if match:
69
74
  return match.group(1).strip()
70
75
  return None
71
76
 
72
77
 
73
- def extract_attribute(text: str, labels: List[str]) -> str | None:
78
+ def extract_attribute(text: str, labels: List[str]) -> Optional[str]:
74
79
  """
75
80
  Extracts the glossary name from a string.
76
81
 
@@ -84,12 +89,15 @@ def extract_attribute(text: str, labels: List[str]) -> str | None:
84
89
  # Iterate over the list of labels
85
90
  for label in labels:
86
91
  # Construct pattern for the current label
87
- pattern = rf"## {re.escape(label)}\n(.*?)(?:##|$)"
92
+ pattern = rf"## {re.escape(label)}\n(.*?)(?:#|---|$)"
88
93
  match = re.search(pattern, text, re.DOTALL)
89
- if match and not match.group(1).isspace(): # Ensure extracted text is not blank
90
- return match.group(1).strip() # Return the matched text
94
+ if match:
95
+ # Extract matched text and replace consecutive \n with a single \n
96
+ extracted_text = re.sub(r'\n+', '\n', match.group(1).strip())
97
+ if not extracted_text.isspace() and extracted_text:
98
+ return extracted_text # Return the cleaned text
91
99
 
92
- return None # Return None if no match is found
100
+ return None
93
101
 
94
102
 
95
103
  def update_a_command(txt: str, command: str, obj_type: str, q_name: str, u_guid: str) -> str:
@@ -119,16 +127,17 @@ def update_a_command(txt: str, command: str, obj_type: str, q_name: str, u_guid:
119
127
  return txt
120
128
 
121
129
  def process_provenance_command(file_path: str, txt: str) -> str:
122
- """This commands processes a provenence command by pre-pending the current file name and time to the provenance output"""
130
+ """This commands processes a provenence command by pre-pending the current file name and time to the provenance
131
+ output"""
123
132
  output = (f"* Derived from processing file {file_path} on "
124
- f"{datetime.now().strftime("%Y-%m-%d %H:%M")}\n")
133
+ f"{get_current_datetime_string()}\n")
125
134
  existing_prov = extract_attribute(txt,'Provenance')
126
- return f"# Provenance:\n{existing_prov}\n{output}\n"
127
-
135
+ existing_prov = existing_prov if existing_prov else " "
136
+ return f"\n# Provenance:\n{existing_prov}\n{output}\n"
128
137
 
129
138
 
130
139
  def process_glossary_upsert_command(egeria_client: EgeriaTech, element_dictionary: dict, txt: str,
131
- directive: str = "display") -> str | None:
140
+ directive: str = "display") -> Optional[str]:
132
141
  """
133
142
  Processes a glossary create or update command by extracting key attributes such as
134
143
  glossary name, language, description, and usage from the given text.
@@ -157,7 +166,7 @@ def process_glossary_upsert_command(egeria_client: EgeriaTech, element_dictionar
157
166
  guid = extract_attribute(txt, ['GUID', 'guid', 'Guid'])
158
167
  glossary_display += f"* Qualified Name: {q_name}\n\t* GUID: {guid}\n\n"
159
168
 
160
- def validate_glossary(obj_action: str) -> tuple[bool, bool, str | None, str | None]:
169
+ def validate_glossary(obj_action: str) -> tuple[bool, bool, Optional[str], Optional[str]]:
161
170
  valid = True
162
171
  msg = ""
163
172
  known_glossary_guid = None
@@ -183,7 +192,7 @@ def process_glossary_upsert_command(egeria_client: EgeriaTech, element_dictionar
183
192
  valid = False
184
193
  if len(glossary_details) == 1:
185
194
  known_glossary_guid = glossary_details[0]['elementHeader'].get('guid', None)
186
- known_q_name = glossary_details[0]['glossaryProperties'].get('qualifiedName', None)
195
+ known_q_name = glossary_details[0]['glossaryProperties'].get('qualifiedName', None).strip()
187
196
 
188
197
  if obj_action == "Update":
189
198
 
@@ -276,7 +285,7 @@ def process_glossary_upsert_command(egeria_client: EgeriaTech, element_dictionar
276
285
 
277
286
 
278
287
  def process_categories_upsert_command(egeria_client: EgeriaTech, element_dictionary: dict, txt: str,
279
- directive: str = "display") -> str | None:
288
+ directive: str = "display") -> Optional[str]:
280
289
  """
281
290
  Processes a glossary category create or update command by extracting key attributes such as
282
291
  category name, qualified, description, and anchor glossary from the given txt..
@@ -306,7 +315,7 @@ def process_categories_upsert_command(egeria_client: EgeriaTech, element_diction
306
315
  category_display += (f"* GUID: {guid}\n\n"
307
316
  f"* Update Description: \n {update_description}\n\t")
308
317
 
309
- def validate_category(obj_action: str) -> tuple[bool, bool, str | None, str | None, str | None]:
318
+ def validate_category(obj_action: str) -> tuple[bool, bool, Optional[str], Optional[str], Optional[str]]:
310
319
  valid = True
311
320
  msg = ""
312
321
  known_category_guid = None
@@ -442,8 +451,9 @@ def process_categories_upsert_command(egeria_client: EgeriaTech, element_diction
442
451
  # return update_a_command(txt, command, object_type, qualified_name, category_guid)
443
452
  return egeria_client.get_categories_by_guid(category_guid, output_format='MD')
444
453
 
454
+
445
455
  def process_term_upsert_command(egeria_client: EgeriaTech, element_dictionary: dict, txt: str,
446
- directive: str = "display") -> str | None:
456
+ directive: str = "display") -> Optional[str]:
447
457
  """
448
458
  Processes a term create or update command by extracting key attributes such as
449
459
  term name, summary, description, abbreviation, examples, usage, version, and status from the given cell.
@@ -477,7 +487,7 @@ def process_term_upsert_command(egeria_client: EgeriaTech, element_dictionary: d
477
487
 
478
488
  print(Markdown(f"{pre_command} `{command}` for term: `\'{term_name}\'` with directive: `{directive}`"))
479
489
 
480
- def validate_term(obj_action: str) -> tuple[bool, bool, str | None, str | None]:
490
+ def validate_term(obj_action: str) -> tuple[bool, bool, Optional[str], Optional[str]]:
481
491
  nonlocal version, status, categories, categories_list, cats_exist, q_name
482
492
  valid = True
483
493
  msg = ""
@@ -525,17 +535,30 @@ def process_term_upsert_command(egeria_client: EgeriaTech, element_dictionary: d
525
535
  else:
526
536
  categories_list = re.split(r'[,\n]+', categories)
527
537
  categories = ""
538
+ new_cat_list = []
528
539
  for category in categories_list:
529
540
  category_el = category.strip()
530
541
  if category_el not in element_dictionary:
531
- cat = egeria_client.get_categories_by_name(category) # assuming qualified name?
542
+ cat = egeria_client.get_categories_by_name(category_el) # assuming qualified name?
532
543
  if isinstance(cat,str):
533
- msg += (f"* {WARNING}Category `{category}` not found -> "
544
+ msg += (f"* {WARNING}Category `{category_el}` not found -> "
534
545
  f"categories for this term won't be processed!\n")
535
546
  cats_exist = False
547
+ break
548
+ cat_qname = cat[0]['glossaryCategoryProperties'].get('qualifiedName', None)
549
+ category = cat_qname # use the qualified name if found
550
+ if cat_qname not in element_dictionary:
551
+ cat_guid = cat[0]['elementHeader']['guid']
552
+ cat_display_name = cat[0]['glossaryCategoryProperties'].get('displayName', None)
553
+ element_dictionary[cat_qname] = {
554
+ 'guid' : cat_guid,
555
+ 'displayName': cat_display_name
556
+ }
536
557
  categories = f"{category}, {categories}"
558
+ new_cat_list.append(category)
537
559
  if cats_exist:
538
560
  categories +='\n'
561
+ categories_list = new_cat_list
539
562
  else:
540
563
  categories = None
541
564
 
@@ -557,7 +580,6 @@ def process_term_upsert_command(egeria_client: EgeriaTech, element_dictionary: d
557
580
  # version = "0.0.1"
558
581
 
559
582
 
560
-
561
583
  if obj_action == "Update": # check to see if provided information exists and is consistent with existing info
562
584
  if not term_exists:
563
585
  msg += f"* {ERROR}Term {term_name} does not exist\n"
@@ -591,10 +613,10 @@ def process_term_upsert_command(egeria_client: EgeriaTech, element_dictionary: d
591
613
  print(Markdown(msg))
592
614
  return valid, term_exists, known_term_guid, known_q_name
593
615
 
594
-
616
+ # Continue processing the upsert
595
617
  if object_action == "Update":
596
618
  term_guid = extract_attribute(txt, 'GUID')
597
- term_guid = term_guid if term_guid else " "
619
+ term_guid = term_guid if term_guid else None
598
620
 
599
621
 
600
622
  update_description = extract_attribute(txt, 'Update Description')
@@ -631,11 +653,19 @@ def process_term_upsert_command(egeria_client: EgeriaTech, element_dictionary: d
631
653
  print(f"\n-->Term {term_name} does not exist")
632
654
  return None
633
655
  body = {
634
- "class": "ReferenceableRequestBody", "elementProperties": {
635
- "class": "GlossaryTermProperties", "qualifiedName": known_q_name, "summary": summary,
636
- "description": description, "abbreviation": abbreviation, "examples": examples, "usage": usage,
637
- "publishVersionIdentifier": version, "status": status
638
- }, "updateDescription": update_description
656
+ "class": "ReferenceableRequestBody",
657
+ "elementProperties": {
658
+ "class": "GlossaryTermProperties",
659
+ "qualifiedName": known_q_name,
660
+ "summary": summary,
661
+ "description": description,
662
+ "abbreviation": abbreviation,
663
+ "examples": examples,
664
+ "usage": usage,
665
+ "publishVersionIdentifier": version,
666
+ "status": status
667
+ },
668
+ "updateDescription": update_description
639
669
  }
640
670
  egeria_client.update_term(known_guid, body)
641
671
  # if cats_exist is True and categories_list is not None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pyegeria
3
- Version: 5.3.6.4
3
+ Version: 5.3.6.5
4
4
  Summary: A python client for Egeria
5
5
  License: Apache 2.0
6
6
  Keywords: egeria,metadata,governance
@@ -1,5 +1,5 @@
1
1
  pyegeria/README.md,sha256=PwX5OC7-YSZUCIsoyHh1O-WBM2hE84sm3Bd4O353NOk,1464
2
- pyegeria/__init__.py,sha256=08v01IyeVZ-YlRZU0qGPAGDhNsdEscX1IHvPcsAYZrE,30187
2
+ pyegeria/__init__.py,sha256=koaCNp-uWubVVhrdGCcd4auWV7qeVKZGAVG1zY0rPgs,30266
3
3
  pyegeria/_client.py,sha256=nhUPmeQFHqbobM6_3EGmUy-STYURxb15BEXf6erY2oI,31733
4
4
  pyegeria/_deprecated_gov_engine.py,sha256=dWNcwVsE5__dF2u4QiIyQrssozzzOjBbLld8MdpmVCQ,17264
5
5
  pyegeria/_exceptions.py,sha256=1SrnV194V4_YJNnNAU0myTHQ3dhLn4GF2B2gZcj1u90,18153
@@ -11,15 +11,16 @@ pyegeria/classification_manager_omvs.py,sha256=n55-62Mby-_5pxPGaz3nkjM9NWlY4PzSl
11
11
  pyegeria/collection_manager_omvs.py,sha256=xNuF3Ki6Rg-TehdbFGS8exSOUXpkQ3X63__OdXuCkc8,101746
12
12
  pyegeria/commands/README.md,sha256=hJdOWhZ5eCfwTkY4Tx6De6Y1XVo7cbaddQEvjqppvls,2036
13
13
  pyegeria/commands/__init__.py,sha256=R2o66ctVicTZ8B5VSPtc7EDRKNiNclzFbYX0o2Zg2dQ,1120
14
+ pyegeria/commands/cat/Dr-Egeria_md-orig.py,sha256=3SCibPi_wq-znp8qeWRJLDYEh4SkAmQaWO5biWeXK2E,7665
14
15
  pyegeria/commands/cat/README.md,sha256=-aaAnIT2fcfU63vajgB-RzQk4l4yFdhkyVfSaTPiqRY,967
15
16
  pyegeria/commands/cat/__init__.py,sha256=5OCy4m_yZsnSxdy_gvkCyP_OkjvuWKimqUGHYCJc_qA,450
16
17
  pyegeria/commands/cat/dr_egeria_inbox/glossary_creation_experiment.ipynb,sha256=dbzNu90fCKNohOWVSRBOB1GLyd95x8Qw51I5AkaPtso,11552
17
18
  pyegeria/commands/cat/dr_egeria_inbox/glossary_exp.md,sha256=KsUeTzDe5QkrTmIfIAXR74qZ29oSfRW-NAEn0RYIRqM,2534
18
19
  pyegeria/commands/cat/dr_egeria_jupyter.py,sha256=4LcmD5CrtazLgUK_LCjgOnwtxZqTBB6lrMR8tsugl94,6036
19
- pyegeria/commands/cat/dr_egeria_md.py,sha256=jMioOrViTFuExh8AlFpJvrEZt4U5I9oUICvKhQPx4D0,7675
20
+ pyegeria/commands/cat/dr_egeria_md.py,sha256=Upro9-273V4LNmQkSWnx7njVNUsuXaWIPfn1HrU6-NI,7830
20
21
  pyegeria/commands/cat/exp_list_glossaries.py,sha256=dC6Bnfm3YSMTKPP146qeslIFRiZnGu5b7iDYE07p4iU,5817
21
22
  pyegeria/commands/cat/get_asset_graph.py,sha256=xnXJfpDTVH1TJ2TwE3dtjaXU36Di6-N6JAyhothzz2o,12461
22
- pyegeria/commands/cat/get_collection.py,sha256=KbSFoGZeK30_bMCa0BpIuCwBF5ywCX0g4hgDPnI0lEo,5356
23
+ pyegeria/commands/cat/get_collection.py,sha256=kXPcP8u-SMWfrVyyBhNoxG8mcgB7EV_5i9N9w_IBU7o,5379
23
24
  pyegeria/commands/cat/get_project_dependencies.py,sha256=wDK_lAfR6p4VxYRV6MZE9XgU3OfIRcWKKYn0Xf64w6o,5986
24
25
  pyegeria/commands/cat/get_project_structure.py,sha256=4Jo3F9f7auTnTt_xElsrQ4eA8k8xMge0C5xE-Rjkjcw,5974
25
26
  pyegeria/commands/cat/get_tech_type_elements.py,sha256=IznytHXwDOFriGM6mypV9wuEeM-vT2s66cUzf-IROog,6147
@@ -224,10 +225,10 @@ pyegeria/egeria_my_client.py,sha256=eOKLk2zdI6FHZnhAimfR_0yNdBjpUgD41dJZcJODcqE,
224
225
  pyegeria/egeria_tech_client.py,sha256=uycgYfCpb4jzFfaQ7I5JxbZ5PKsWdaWxLOJjbw6C2Zk,3817
225
226
  pyegeria/feedback_manager_omvs.py,sha256=0xBs0p54vmdfVYYgQ8pOanLC4fxfgTk1Z61Y6D1U7_I,152978
226
227
  pyegeria/full_omag_server_config.py,sha256=CQqLCy_3DZFvJZEOcGf50HWdFaWpiAIs6z-kKyjvpDA,47464
227
- pyegeria/glossary_browser_omvs.py,sha256=r8PYlNTN-Ej2pGg1SigKQn8Qu1wDmFvWG5vM2I12JyI,109391
228
+ pyegeria/glossary_browser_omvs.py,sha256=kJPfVd46w7HdV2KKoq7jRxVYdvvqEl0RAIMRsfXrtME,109389
228
229
  pyegeria/glossary_manager_omvs.py,sha256=QSOVqbwEASueCQzpvYNEOaUIAhOvwqLWWhfzwT8hrrs,70275
229
230
  pyegeria/m_test.py,sha256=M5-M2ZczsAJLXWfSeqTTADHdx6Ku-y4PbQ4M21JthAE,7778
230
- pyegeria/md_processing_utils.py,sha256=FiZqeN39YH9LeZvzY_YZ8wo6DnRRvQif3-BBHLebcBg,40329
231
+ pyegeria/md_processing_utils.py,sha256=8ucemhlOniobCn8ZSWN3D9-JaeZkgHJAwy2K2xWx3Bo,41759
231
232
  pyegeria/mermaid_utilities.py,sha256=sQqdFUWdNpHu9d3Tk9UVe80M-5bOzses0XcFYX5FF-E,54254
232
233
  pyegeria/metadata_explorer_omvs.py,sha256=xHnZTQKbd6XwOhYia-RiIisrvZcqHi0SL1l6OCf04Gk,86911
233
234
  pyegeria/my_profile_omvs.py,sha256=d0oJYCJG7pS9BINPuGciVa00ac0jwPHNANXDCLginEc,34720
@@ -241,8 +242,8 @@ pyegeria/template_manager_omvs.py,sha256=PfJ9dOfmBvf59DgRdZ9Dl1Kl_UYqjF-JncXVnbC
241
242
  pyegeria/utils.py,sha256=GCt1C0bp0Xng1ahzbZhzV9qQwH7Dj93IaCt2dvWb-sg,5417
242
243
  pyegeria/valid_metadata_omvs.py,sha256=Xq9DqBQvBFFJzaFIRKcVZ2k4gJvSh9yeXs_j-O3vn1w,65050
243
244
  pyegeria/x_action_author_omvs.py,sha256=RcqSzahUKCtvb_3u_wyintAlc9WFkC_2v0E12TZs8lQ,6433
244
- pyegeria-5.3.6.4.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
245
- pyegeria-5.3.6.4.dist-info/METADATA,sha256=yd4UPOQI1S90JJ0hO89N5EIKSu6t5CvWuywJ9c4PFh4,2743
246
- pyegeria-5.3.6.4.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
247
- pyegeria-5.3.6.4.dist-info/entry_points.txt,sha256=eAvQ_vkejlF3JzMzEc5VD93ymLA_hSFV0HM8fntG-d8,6791
248
- pyegeria-5.3.6.4.dist-info/RECORD,,
245
+ pyegeria-5.3.6.5.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
246
+ pyegeria-5.3.6.5.dist-info/METADATA,sha256=GrlrzX8hGY3vjq6vYSrSbGYgAxRqsLe1L2BQCLnC9O8,2743
247
+ pyegeria-5.3.6.5.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
248
+ pyegeria-5.3.6.5.dist-info/entry_points.txt,sha256=eAvQ_vkejlF3JzMzEc5VD93ymLA_hSFV0HM8fntG-d8,6791
249
+ pyegeria-5.3.6.5.dist-info/RECORD,,