pyegeria 5.4.0.dev6__py3-none-any.whl → 5.4.0.dev8__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.
@@ -16,6 +16,7 @@ from md_processing.md_processing_utils.extraction_utils import (extract_command_
16
16
  from md_processing.md_processing_utils.md_processing_constants import (load_commands, ERROR)
17
17
  from pyegeria import DEBUG_LEVEL, body_slimmer
18
18
  from pyegeria.egeria_tech_client import EgeriaTech
19
+ from pyegeria.output_formatter import (extract_mermaid_only, extract_basic_dict, generate_output)
19
20
 
20
21
 
21
22
  GERIA_METADATA_STORE = os.environ.get("EGERIA_METADATA_STORE", "active-metadata-store")
@@ -1422,7 +1423,7 @@ def process_data_collection_list_command(egeria_client: EgeriaTech, txt: str, di
1422
1423
  attributes = parsed_output['attributes']
1423
1424
 
1424
1425
  valid = parsed_output['valid']
1425
-
1426
+ print(Markdown(f"Performing {command}"))
1426
1427
  print(Markdown(parsed_output['display']))
1427
1428
 
1428
1429
  if directive == "display":
@@ -1485,7 +1486,7 @@ def process_data_structure_list_command(egeria_client: EgeriaTech, txt: str, dir
1485
1486
  attributes = parsed_output['attributes']
1486
1487
 
1487
1488
  valid = parsed_output['valid']
1488
-
1489
+ print(Markdown(f"Performing {command}"))
1489
1490
  print(Markdown(parsed_output['display']))
1490
1491
 
1491
1492
  if directive == "display":
@@ -1545,7 +1546,7 @@ def process_data_field_list_command(egeria_client: EgeriaTech, txt: str, directi
1545
1546
  attributes = parsed_output['attributes']
1546
1547
 
1547
1548
  valid = parsed_output['valid']
1548
-
1549
+ print(Markdown(f"Performing {command}"))
1549
1550
  print(Markdown(parsed_output['display']))
1550
1551
 
1551
1552
  if directive == "display":
@@ -1563,6 +1564,15 @@ def process_data_field_list_command(egeria_client: EgeriaTech, txt: str, directi
1563
1564
  search_string = attributes.get('Search String', {}).get('value', '*')
1564
1565
  output_format = attributes.get('Output Format', {}).get('value', 'LIST')
1565
1566
  detailed = attributes.get('Detailed', {}).get('value', False)
1567
+ as_of_time = attributes.get('AsOfTime', {}).get('value', None)
1568
+ effective_time = attributes.get('Effective Time', {}).get('value', None)
1569
+ sort_order = attributes.get('Sort Order', {}).get('value', None)
1570
+ order_property = attributes.get('Order Property', {}).get('value', None)
1571
+ starts_with = attributes.get('Start With', {}).get('value', True)
1572
+ ends_with = attributes.get('End With', {}).get('value', False)
1573
+ ignore_case = attributes.get('Ignore Case', {}).get('value', False)
1574
+ start_from = attributes.get('Start From', {}).get('value', 0)
1575
+ page_size = attributes.get('Page Size', {}).get('value', None)
1566
1576
 
1567
1577
  try:
1568
1578
  if not valid: # First validate the command before we process it
@@ -1571,7 +1581,19 @@ def process_data_field_list_command(egeria_client: EgeriaTech, txt: str, directi
1571
1581
  return None
1572
1582
 
1573
1583
  list_md = f"\n# `{object_type}` with filter: `{search_string}`\n\n"
1574
- struct = egeria_client.find_data_fields(search_string, output_format=output_format)
1584
+ body = {
1585
+ "class": "FilterRequestBody",
1586
+ "asOfTime": as_of_time,
1587
+ "effectiveTime": effective_time,
1588
+ "forLineage": False,
1589
+ "forDuplicateProcessing" : False,
1590
+ "limitResultsByStatus": ["ACTIVE"],
1591
+ "sequencingOrder": sort_order,
1592
+ "sequencingProperty": order_property,
1593
+ "filter": search_string,
1594
+ }
1595
+ struct = egeria_client.find_data_fields_w_body(body, start_from, page_size, starts_with,
1596
+ ends_with, ignore_case,output_format)
1575
1597
 
1576
1598
  if output_format == "DICT":
1577
1599
  list_md += f"```\n{json.dumps(struct, indent=4)}\n```\n"
@@ -1605,7 +1627,7 @@ def process_data_class_list_command(egeria_client: EgeriaTech, txt: str, directi
1605
1627
  attributes = parsed_output['attributes']
1606
1628
 
1607
1629
  valid = parsed_output['valid']
1608
-
1630
+ print(Markdown(f"Performing {command}"))
1609
1631
  print(Markdown(parsed_output['display']))
1610
1632
 
1611
1633
  if directive == "display":
@@ -1648,125 +1670,4 @@ def process_data_class_list_command(egeria_client: EgeriaTech, txt: str, directi
1648
1670
  else:
1649
1671
  return None
1650
1672
 
1651
- # @logger.catch
1652
- # def process_list_data_dictionary_command(egeria_client: EgeriaTech, txt: str, directive: str = "display") ->
1653
- # Optional[str]:
1654
- # """
1655
- # Processes a list data dictionary.
1656
- #
1657
- # :param txt: A string representing the input cell to be processed for
1658
- # extracting term-related attributes.
1659
- # :param directive: an optional string indicating the directive to be used - display, validate or execute
1660
- # :return: A string summarizing the outcome of the processing.
1661
- # """
1662
- #
1663
- #
1664
- # if directive == "display":
1665
- # print(Markdown(f"\n* Command: {object_action}\n\t* Term Name: {term_name}\n\t* Output Format: {
1666
- # output_format}"))
1667
- # return None
1668
- # elif directive == "validate":
1669
- # print(Markdown(f"\n* Command: {object_action}\n\t* Term Name: {term_name}\n\t* Output Format: {
1670
- # output_format}"))
1671
- # return True
1672
- # elif directive == "process":
1673
- # print(Markdown(f"\n* Command: {object_action}\n\t* Term Name: {term_name}\n\t* Output Format: {
1674
- # output_format}"))
1675
- # return egeria_client.get_term_by_guid(known_guid, output_format=output_format)
1676
1673
 
1677
- #
1678
- # def process_term_history_command(egeria_client: EgeriaTech, txt: str, directive: str = "display") -> Optional[str]:
1679
- # """
1680
- # Processes a term history object_action by extracting key attributes such as
1681
- # term name and output format from the given text.
1682
- #
1683
- # :param txt: A string representing the input cell to be processed for
1684
- # extracting term-related attributes.
1685
- # :param directive: an optional string indicating the directive to be used - display, validate or execute
1686
- # :return: A string summarizing the outcome of the processing.
1687
- # """
1688
- # from md_processing.md_processing_utils.common_md_utils import set_debug_level
1689
- #
1690
- # object_action = extract_command(txt)
1691
- # set_debug_level(directive)
1692
- # print(Markdown(f"{pre_command} `{object_action}` with directive: `{directive}`"))
1693
- #
1694
- # term_name = process_simple_attribute(txt, TERM_NAME_LABELS, ERROR)
1695
- # output_format = process_simple_attribute(txt, OUTPUT_LABELS)
1696
- # output_format = output_format.upper() if output_format else "MD"
1697
- # if output_format not in ELEMENT_OUTPUT_FORMATS:
1698
- # print_msg(WARNING, f"Output format {output_format} not recognized, using MD", debug_level)
1699
- # output_format = "MD"
1700
- #
1701
- # if term_name is None:
1702
- # print_msg(ERROR, "No term name found", debug_level)
1703
- # return None
1704
- #
1705
- # known_q_name, known_guid, valid, term_exists = process_element_identifiers(egeria_client, "Term",
1706
- # TERM_NAME_LABELS, txt,
1707
- # EXISTS_REQUIRED, None)
1708
- # if not term_exists:
1709
- # print_msg(ERROR, f"Term {term_name} not found", debug_level)
1710
- # return None
1711
- #
1712
- # if directive == "display":
1713
- # print(Markdown(f"\n* Command: {object_action}\n\t* Term Name: {term_name}\n\t* Output Format: {
1714
- # output_format}"))
1715
- # return None
1716
- # elif directive == "validate":
1717
- # print(Markdown(f"\n* Command: {object_action}\n\t* Term Name: {term_name}\n\t* Output Format: {
1718
- # output_format}"))
1719
- # return True
1720
- # elif directive == "process":
1721
- # print(Markdown(f"\n* Command: {object_action}\n\t* Term Name: {term_name}\n\t* Output Format: {
1722
- # output_format}"))
1723
- # return egeria_client.get_term_history(known_guid, output_format=output_format)
1724
- #
1725
- #
1726
- # def process_term_revision_history_command(egeria_client: EgeriaTech, txt: str, directive: str = "display") ->
1727
- # Optional[str]:
1728
- # """
1729
- # Processes a term revision history object_action by extracting key attributes such as
1730
- # term name and output format from the given text.
1731
- #
1732
- # :param txt: A string representing the input cell to be processed for
1733
- # extracting term-related attributes.
1734
- # :param directive: an optional string indicating the directive to be used - display, validate or execute
1735
- # :return: A string summarizing the outcome of the processing.
1736
- # """
1737
- # from md_processing.md_processing_utils.common_md_utils import set_debug_level
1738
- #
1739
- # object_action = extract_command(txt)
1740
- # set_debug_level(directive)
1741
- # print(Markdown(f"{pre_command} `{object_action}` with directive: `{directive}`"))
1742
- #
1743
- # term_name = process_simple_attribute(txt, TERM_NAME_LABELS, ERROR)
1744
- # output_format = process_simple_attribute(txt, OUTPUT_LABELS)
1745
- # output_format = output_format.upper() if output_format else "MD"
1746
- # if output_format not in ELEMENT_OUTPUT_FORMATS:
1747
- # print_msg(WARNING, f"Output format {output_format} not recognized, using MD", debug_level)
1748
- # output_format = "MD"
1749
- #
1750
- # if term_name is None:
1751
- # print_msg(ERROR, "No term name found", debug_level)
1752
- # return None
1753
- #
1754
- # known_q_name, known_guid, valid, term_exists = process_element_identifiers(egeria_client, "Term",
1755
- # TERM_NAME_LABELS, txt,
1756
- # EXISTS_REQUIRED, None)
1757
- # if not term_exists:
1758
- # print_msg(ERROR, f"Term {term_name} not found", debug_level)
1759
- # return None
1760
- #
1761
- # if directive == "display":
1762
- # print(Markdown(f"\n* Command: {object_action}\n\t* Term Name: {term_name}\n\t* Output Format: {
1763
- # output_format}"))
1764
- # return None
1765
- # elif directive == "validate":
1766
- # print(Markdown(f"\n* Command: {object_action}\n\t* Term Name: {term_name}\n\t* Output Format: {
1767
- # output_format}"))
1768
- # return True
1769
- # elif directive == "process":
1770
- # print(Markdown(f"\n* Command: {object_action}\n\t* Term Name: {term_name}\n\t* Output Format: {
1771
- # output_format}"))
1772
- # return egeria_client.get_term_revision_history(known_guid, output_format=output_format)
File without changes
@@ -0,0 +1,150 @@
1
+ """
2
+ This file contains general utility functions for processing Egeria Markdown
3
+ """
4
+ import json
5
+ import os
6
+ import sys
7
+ from typing import List
8
+
9
+ from loguru import logger
10
+ from rich import print
11
+ from rich.console import Console
12
+ from rich.markdown import Markdown
13
+
14
+ from commands.cat.dr_egeria_command_help import EGERIA_INBOX_PATH
15
+ from md_processing.md_processing_utils.common_md_utils import (get_current_datetime_string, get_element_dictionary,
16
+ update_element_dictionary,
17
+ split_tb_string, str_to_bool, )
18
+ from md_processing.md_processing_utils.extraction_utils import (process_simple_attribute, extract_attribute,
19
+ get_element_by_name)
20
+ from md_processing.md_processing_utils.md_processing_constants import (get_command_spec, load_commands, load_commands, COMMAND_DEFINITIONS)
21
+
22
+ from md_processing.md_processing_utils.message_constants import (ERROR, INFO, WARNING, ALWAYS, EXISTS_REQUIRED)
23
+ from pyegeria import EgeriaTech
24
+ from pyegeria._globals import DEBUG_LEVEL
25
+ from pyegeria.output_formatter import generate_entity_md_table
26
+
27
+ # Constants
28
+ EGERIA_WIDTH = int(os.environ.get("EGERIA_WIDTH", "200"))
29
+ EGERIA_ROOT_PATH = os.environ.get("EGERIA_ROOT_PATH", ".")
30
+ EGERIA_INBOX_PATH = os.environ.get("EGERIA_INBOX_PATH", ".")
31
+
32
+ console = Console(width=EGERIA_WIDTH)
33
+
34
+ debug_level = DEBUG_LEVEL
35
+ global COMMAND_DEFINITIONS
36
+
37
+ load_commands('commands.json')
38
+
39
+
40
+ log_format = "D {time} | {level} | {function} | {line} | {message} | {extra}"
41
+ logger.remove()
42
+ logger.add(sys.stderr, level="INFO", format=log_format, colorize=True)
43
+ full_file_path = os.path.join(EGERIA_ROOT_PATH, EGERIA_INBOX_PATH, "data_designer_debug.log")
44
+ # logger.add(full_file_path, rotation="1 day", retention="1 week", compression="zip", level="TRACE", format=log_format,
45
+ # colorize=True)
46
+ logger.add("debug_log", rotation="1 day", retention="1 week", compression="zip", level="TRACE", format=log_format,
47
+ colorize=True)
48
+ def yes_no(input: str)->str:
49
+ if type(input) is bool:
50
+ if input:
51
+ return "True"
52
+ else:
53
+ return "False"
54
+
55
+ input = input.title()
56
+ if input in ["Yes","No"]:
57
+ return input
58
+
59
+ if input in ["True", "T"]:
60
+ return "Yes"
61
+ else:
62
+ return "No"
63
+
64
+ @logger.catch
65
+ def _extract_help_fields(command: dict):
66
+ """
67
+
68
+ """
69
+
70
+ command_spec = get_command_spec(command)
71
+ attributes = command_spec.get('Attributes', [])
72
+ command_display_name = command_spec.get('display_name', None)
73
+ command_qn_prefix = command_spec.get('qn_prefix', None)
74
+
75
+ term_entry: list = []
76
+ for attr in attributes:
77
+ for key in attr:
78
+ if attr[key].get('level','Basic') != "Basic":
79
+ continue
80
+ attribute_name = key
81
+ input_required = yes_no(attr[key].get('input_required', "No"))
82
+
83
+ read_only = yes_no(attr[key].get('user_specified', "No"))
84
+ generated = yes_no(attr[key].get('generated', "No"))
85
+ default = attr[key].get('default', None)
86
+ if default:
87
+ generated = default
88
+ unique = yes_no(attr[key].get('unique', "No"))
89
+ notes = attr[key].get('description', "")
90
+ valid_values = attr[key].get('valid_values', [])
91
+ term_entry.append ({
92
+ 'Attribute Name' : attribute_name,
93
+ 'Input Required' : input_required,
94
+ 'Read Only' : read_only,
95
+ 'Generated' : generated,
96
+ 'Default Value' : default,
97
+ 'Notes' : notes,
98
+ 'Unique Values' : unique,
99
+ 'Valid Values' : valid_values,
100
+ })
101
+
102
+ return term_entry
103
+
104
+ def create_help_terms():
105
+ term_entry:str = ""
106
+ glossary_name = "Egeria-Markdown"
107
+ commands = COMMAND_DEFINITIONS["Command Specifications"]
108
+ columns = [{'name': "Attribute Name", 'key': 'Attribute Name'},
109
+ {'name': 'Input Required', 'key': 'Input Required'},
110
+ {'name': 'Read Only', 'key': 'Read Only'},
111
+ {'name': 'Generated', 'key': 'Generated'},
112
+ {'name': 'Default Value', 'key': 'Default Value'},
113
+ {'name': 'Notes', 'key': 'Notes'},
114
+ {'name': 'Unique Values', 'key': 'Unique Values'},
115
+ {'name': 'Valid Values', 'key': 'Valid Values'}]
116
+
117
+ term_entry = """# Generating glossary entries for the documented commands\n\n
118
+ This file contains generated Dr.Egeria commands to generate glossary term entries describing
119
+ each command represented in the `commands.json` file.\n"""
120
+
121
+ for command, values in commands.items():
122
+ if command == "exported":
123
+ continue
124
+ if commands[command].get("level","") not in ["Basic"]:
125
+ continue
126
+ command_description = commands[command].get("description","")
127
+ command_verb = commands[command].get("verb","")
128
+
129
+ term_entry+= "# Create Term\n"
130
+ term_entry+= f"## Term Name\n\n{command_verb} {command}\n\n"
131
+ term_entry+= f"## Description\n\n{command_description}\n\n"
132
+ term_entry+= f"## Owning Glossary\n\n{glossary_name}\n\n"
133
+ term_entry+= f"## Categories\n\nWriting Dr.Egeria Markdown\n\n"
134
+
135
+
136
+ du = _extract_help_fields(command)
137
+ output = generate_entity_md_table(du, "", "", _extract_help_fields, columns, None, "help" )
138
+
139
+ term_entry+= f"## Usage\n\n{output}\n\n___\n\n"
140
+ print(term_entry)
141
+ file_path = os.path.join(EGERIA_ROOT_PATH, EGERIA_INBOX_PATH, "generated_help_terms.md")
142
+ with open(file_path, 'a', encoding="utf-8") as f:
143
+ f.write(term_entry)
144
+
145
+ def main():
146
+ create_help_terms()
147
+
148
+
149
+ if __name__ == "__main__":
150
+ main()
@@ -0,0 +1,92 @@
1
+ """
2
+ This file contains general utility functions for processing Egeria Markdown
3
+ """
4
+ import os
5
+ import sys
6
+ from typing import List
7
+
8
+ from loguru import logger
9
+ from rich import print
10
+ from rich.console import Console
11
+
12
+ from commands.cat.dr_egeria_command_help import EGERIA_INBOX_PATH
13
+ from md_processing.md_processing_utils.common_md_utils import (get_current_datetime_string, get_element_dictionary,
14
+ update_element_dictionary,
15
+ split_tb_string, str_to_bool, )
16
+ from md_processing.md_processing_utils.extraction_utils import (process_simple_attribute, extract_attribute,
17
+ get_element_by_name)
18
+ from md_processing.md_processing_utils.md_processing_constants import (get_command_spec, load_commands, load_commands, COMMAND_DEFINITIONS)
19
+
20
+ from md_processing.md_processing_utils.message_constants import (ERROR, INFO, WARNING, ALWAYS, EXISTS_REQUIRED)
21
+ from pyegeria import EgeriaTech
22
+ from pyegeria._globals import DEBUG_LEVEL
23
+
24
+
25
+ # Constants
26
+ EGERIA_WIDTH = int(os.environ.get("EGERIA_WIDTH", "200"))
27
+ EGERIA_ROOT_PATH = os.environ.get("EGERIA_ROOT_PATH", ".")
28
+ EGERIA_INBOX_PATH = os.environ.get("EGERIA_INBOX_PATH", ".")
29
+
30
+ console = Console(width=EGERIA_WIDTH)
31
+
32
+ debug_level = DEBUG_LEVEL
33
+ global COMMAND_DEFINITIONS
34
+
35
+ load_commands('commands.json')
36
+
37
+
38
+ log_format = "D {time} | {level} | {function} | {line} | {message} | {extra}"
39
+ logger.remove()
40
+ logger.add(sys.stderr, level="INFO", format=log_format, colorize=True)
41
+ full_file_path = os.path.join(EGERIA_ROOT_PATH, EGERIA_INBOX_PATH, "data_designer_debug.log")
42
+ # logger.add(full_file_path, rotation="1 day", retention="1 week", compression="zip", level="TRACE", format=log_format,
43
+ # colorize=True)
44
+ logger.add("debug_log", rotation="1 day", retention="1 week", compression="zip", level="TRACE", format=log_format,
45
+ colorize=True)
46
+ @logger.catch
47
+ def main():
48
+ """
49
+
50
+ """
51
+ glossary_name = "Egeria-Markdown"
52
+ commands = COMMAND_DEFINITIONS["Command Specifications"]
53
+ for command, values in commands.items():
54
+ if command == "exported":
55
+ continue
56
+ if commands[command].get("level","") not in ["Basic"]:
57
+ continue
58
+ command_description = commands[command].get("description","")
59
+ command_verb = commands[command].get("verb","")
60
+ print(f"\n# {command_verb} {command}\n>\t{command_description}")
61
+
62
+ attributes = commands[command]['Attributes']
63
+ for attribute in attributes:
64
+ for key, value in attribute.items():
65
+ if value.get('level',"") not in ["Basic"]:
66
+ continue
67
+ user_specified = value.get('user_specified', 'true') in ["true", "True"]
68
+
69
+ print(f"\n## {key}")
70
+
71
+ print(f">\tInput Required: {value.get('input_required', "false")}")
72
+
73
+ print(f">\tDescription: {value.get("description","")}")
74
+ labels = value.get("attr_labels", None)
75
+ if labels:
76
+ print(f">\tAlternative Labels: {labels}")
77
+
78
+ valid_values = value.get("valid_values", None)
79
+ if valid_values:
80
+ print(f">\tValid Values: {valid_values}")
81
+ default_value = value.get("default_value", None)
82
+ if default_value:
83
+ print(f">\tDefault Value: {default_value}")
84
+ print("\n___\n")
85
+
86
+
87
+
88
+
89
+ #
90
+
91
+ if __name__ == "__main__":
92
+ main()