pyegeria 5.4.0.30__py3-none-any.whl → 5.4.0.32__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 (122) hide show
  1. commands/cat/dr_egeria_md.py +8 -260
  2. md_processing/__init__.py +2 -2
  3. md_processing/dr_egeria.py +309 -0
  4. md_processing/md_commands/data_designer_commands.py +1 -2
  5. md_processing/md_commands/glossary_commands.py +2 -3
  6. md_processing/md_commands/governance_officer_commands.py +1 -2
  7. md_processing/md_commands/product_manager_commands.py +1 -2
  8. md_processing/md_commands/project_commands.py +1 -3
  9. md_processing/md_commands/solution_architect_commands.py +1 -2
  10. md_processing/md_processing_utils/common_md_proc_utils.py +1 -1
  11. md_processing/md_processing_utils/common_md_utils.py +8 -11
  12. pyegeria/__init__.py +19 -2
  13. {pyegeria-5.4.0.30.dist-info → pyegeria-5.4.0.32.dist-info}/METADATA +1 -1
  14. {pyegeria-5.4.0.30.dist-info → pyegeria-5.4.0.32.dist-info}/RECORD +17 -121
  15. commands/.DS_Store +0 -0
  16. commands/cat/.DS_Store +0 -0
  17. commands/cat/.env +0 -8
  18. commands/cat/debug_log +0 -1126
  19. commands/cat/debug_log.2025-08-18_11-34-38_088636.zip +0 -0
  20. commands/cat/debug_log.log +0 -0
  21. commands/cat/logs/pyegeria.log +0 -4
  22. commands/cli/debug_log.log +0 -0
  23. commands/doc/.DS_Store +0 -0
  24. commands/ops/logs/pyegeria.log +0 -0
  25. md_processing/.DS_Store +0 -0
  26. md_processing/dr_egeria_inbox/Derive-Dr-Gov-Defs.md +0 -8
  27. md_processing/dr_egeria_inbox/Dr.Egeria Templates.md +0 -873
  28. md_processing/dr_egeria_inbox/arch_test.md +0 -57
  29. md_processing/dr_egeria_inbox/archive/dr_egeria_intro.md +0 -254
  30. md_processing/dr_egeria_inbox/archive/dr_egeria_intro_more_terms.md +0 -696
  31. md_processing/dr_egeria_inbox/archive/dr_egeria_intro_part1.md +0 -254
  32. md_processing/dr_egeria_inbox/archive/dr_egeria_intro_part2.md +0 -298
  33. md_processing/dr_egeria_inbox/archive/dr_egeria_intro_part3.md +0 -608
  34. md_processing/dr_egeria_inbox/archive/dr_egeria_intro_part4.md +0 -94
  35. md_processing/dr_egeria_inbox/archive/freddie_intro.md +0 -284
  36. md_processing/dr_egeria_inbox/archive/freddie_intro_orig.md +0 -275
  37. md_processing/dr_egeria_inbox/archive/test-term.md +0 -110
  38. md_processing/dr_egeria_inbox/cat_test.md +0 -100
  39. md_processing/dr_egeria_inbox/collections.md +0 -39
  40. md_processing/dr_egeria_inbox/data_designer_debug.log +0 -6
  41. md_processing/dr_egeria_inbox/data_designer_out.md +0 -60
  42. md_processing/dr_egeria_inbox/data_designer_search_test.md +0 -11
  43. md_processing/dr_egeria_inbox/data_field.md +0 -54
  44. md_processing/dr_egeria_inbox/data_spec.md +0 -77
  45. md_processing/dr_egeria_inbox/data_spec_test.md +0 -2406
  46. md_processing/dr_egeria_inbox/data_test.md +0 -179
  47. md_processing/dr_egeria_inbox/data_test2.md +0 -429
  48. md_processing/dr_egeria_inbox/data_test3.md +0 -462
  49. md_processing/dr_egeria_inbox/dr_egeria_data_designer_1.md +0 -124
  50. md_processing/dr_egeria_inbox/dr_egeria_intro_categories.md +0 -168
  51. md_processing/dr_egeria_inbox/dr_egeria_intro_part1.md +0 -280
  52. md_processing/dr_egeria_inbox/dr_egeria_intro_part2.md +0 -318
  53. md_processing/dr_egeria_inbox/dr_egeria_intro_part3.md +0 -1073
  54. md_processing/dr_egeria_inbox/dr_egeria_isc1.md +0 -44
  55. md_processing/dr_egeria_inbox/generated_help_report.md +0 -9
  56. md_processing/dr_egeria_inbox/glossary_list.md +0 -5
  57. md_processing/dr_egeria_inbox/glossary_search_test.md +0 -40
  58. md_processing/dr_egeria_inbox/glossary_test1.md +0 -324
  59. md_processing/dr_egeria_inbox/gov_def.md +0 -482
  60. md_processing/dr_egeria_inbox/gov_def2.md +0 -447
  61. md_processing/dr_egeria_inbox/img.png +0 -0
  62. md_processing/dr_egeria_inbox/product.md +0 -211
  63. md_processing/dr_egeria_inbox/rel.md +0 -8
  64. md_processing/dr_egeria_inbox/sb.md +0 -119
  65. md_processing/dr_egeria_inbox/solution-components.md +0 -136
  66. md_processing/dr_egeria_inbox/solution_blueprints.md +0 -118
  67. md_processing/dr_egeria_inbox/synonym_test.md +0 -42
  68. md_processing/dr_egeria_inbox/t2.md +0 -268
  69. md_processing/dr_egeria_outbox/.obsidian/app.json +0 -1
  70. md_processing/dr_egeria_outbox/.obsidian/appearance.json +0 -1
  71. md_processing/dr_egeria_outbox/.obsidian/community-plugins.json +0 -6
  72. md_processing/dr_egeria_outbox/.obsidian/core-plugins.json +0 -31
  73. md_processing/dr_egeria_outbox/.obsidian/plugins/calendar/data.json +0 -10
  74. md_processing/dr_egeria_outbox/.obsidian/plugins/calendar/main.js +0 -4459
  75. md_processing/dr_egeria_outbox/.obsidian/plugins/calendar/manifest.json +0 -10
  76. md_processing/dr_egeria_outbox/.obsidian/plugins/obsidian-kanban/data.json +0 -3
  77. md_processing/dr_egeria_outbox/.obsidian/plugins/obsidian-kanban/main.js +0 -153
  78. md_processing/dr_egeria_outbox/.obsidian/plugins/obsidian-kanban/manifest.json +0 -11
  79. md_processing/dr_egeria_outbox/.obsidian/plugins/obsidian-kanban/styles.css +0 -1
  80. md_processing/dr_egeria_outbox/.obsidian/plugins/obsidian-tasks-plugin/main.js +0 -500
  81. md_processing/dr_egeria_outbox/.obsidian/plugins/obsidian-tasks-plugin/manifest.json +0 -12
  82. md_processing/dr_egeria_outbox/.obsidian/plugins/obsidian-tasks-plugin/styles.css +0 -1
  83. md_processing/dr_egeria_outbox/.obsidian/plugins/templater-obsidian/main.js +0 -37
  84. md_processing/dr_egeria_outbox/.obsidian/plugins/templater-obsidian/manifest.json +0 -11
  85. md_processing/dr_egeria_outbox/.obsidian/plugins/templater-obsidian/styles.css +0 -220
  86. md_processing/dr_egeria_outbox/.obsidian/types.json +0 -28
  87. md_processing/dr_egeria_outbox/.obsidian/workspace.json +0 -220
  88. md_processing/dr_egeria_outbox/Untitled.canvas +0 -1
  89. md_processing/dr_egeria_outbox/friday/processed-2025-08-22 21:22-dr_egeria_intro_part1.md +0 -312
  90. md_processing/dr_egeria_outbox/friday/processed-2025-08-22 21:23-dr_egeria_intro_part1.md +0 -265
  91. md_processing/dr_egeria_outbox/friday/processed-2025-08-23 15:06-dr_egeria_intro_part1.md +0 -230
  92. md_processing/dr_egeria_outbox/friday/processed-2025-08-23 15:30-dr_egeria_intro_part1.md +0 -296
  93. md_processing/dr_egeria_outbox/friday/processed-2025-08-23 15:31-dr_egeria_intro_part1.md +0 -253
  94. md_processing/dr_egeria_outbox/friday/processed-2025-08-23 16:08-dr_egeria_intro_part2.md +0 -343
  95. md_processing/dr_egeria_outbox/friday/processed-2025-08-23 16:12-dr_egeria_intro_part2.md +0 -343
  96. md_processing/dr_egeria_outbox/monday/processed-2025-08-19 07:05-product.md +0 -426
  97. md_processing/dr_egeria_outbox/monday/processed-2025-08-19 07:56-product.md +0 -212
  98. md_processing/dr_egeria_outbox/monday/processed-2025-08-19 09:43-product.md +0 -201
  99. md_processing/dr_egeria_outbox/sunday/processed-2025-07-20 14:55-product.md +0 -77
  100. md_processing/dr_egeria_outbox/sunday/processed-2025-07-20 15:05-product.md +0 -75
  101. md_processing/dr_egeria_outbox/sunday/processed-2025-07-20 15:11-product.md +0 -74
  102. md_processing/dr_egeria_outbox/sunday/processed-2025-07-20 20:40-collections.md +0 -49
  103. md_processing/dr_egeria_outbox/thursday/processed-2025-07-17 15:00-Derive-Dr-Gov-Defs.md +0 -719
  104. md_processing/dr_egeria_outbox/thursday/processed-2025-07-17 20:13-Derive-Dr-Gov-Defs.md +0 -41
  105. md_processing/dr_egeria_outbox/thursday/processed-2025-07-17 20:14-Derive-Dr-Gov-Defs.md +0 -33
  106. md_processing/dr_egeria_outbox/thursday/processed-2025-07-17 20:50-Derive-Dr-Gov-Defs.md +0 -192
  107. md_processing/dr_egeria_outbox/thursday/processed-2025-07-17 22:08-gov_def2.md +0 -486
  108. md_processing/dr_egeria_outbox/thursday/processed-2025-07-17 22:10-gov_def2.md +0 -486
  109. md_processing/dr_egeria_outbox/thursday/processed-2025-07-18 08:53-gov_def2.md +0 -486
  110. md_processing/dr_egeria_outbox/thursday/processed-2025-07-18 08:54-gov_def2.md +0 -486
  111. md_processing/dr_egeria_outbox/thursday/processed-2025-07-18 09:03-gov_def2.md +0 -486
  112. md_processing/dr_egeria_outbox/thursday/processed-2025-07-18 09:06-gov_def2.md +0 -486
  113. md_processing/dr_egeria_outbox/thursday/processed-2025-07-18 09:10-gov_def2.md +0 -486
  114. md_processing/dr_egeria_outbox/tuesday/processed-2025-07-16 19:15-gov_def2.md +0 -527
  115. md_processing/dr_egeria_outbox/tuesday/processed-2025-07-17 12:08-gov_def2.md +0 -527
  116. md_processing/dr_egeria_outbox/tuesday/processed-2025-07-17 14:27-gov_def2.md +0 -485
  117. md_processing/dr_egeria_outbox/tuesday/processed-2025-08-19 10:55-product.md +0 -209
  118. md_processing/md_processing_utils/debug_log.log +0 -0
  119. pyegeria/.DS_Store +0 -0
  120. {pyegeria-5.4.0.30.dist-info → pyegeria-5.4.0.32.dist-info}/LICENSE +0 -0
  121. {pyegeria-5.4.0.30.dist-info → pyegeria-5.4.0.32.dist-info}/WHEEL +0 -0
  122. {pyegeria-5.4.0.30.dist-info → pyegeria-5.4.0.32.dist-info}/entry_points.txt +0 -0
@@ -16,36 +16,10 @@ logger.add("debug_log.log", rotation="1 day", retention="1 week", compression="z
16
16
  import click
17
17
  from rich import print
18
18
  from rich.console import Console
19
- from md_processing.md_processing_utils.common_md_utils import setup_log
20
19
 
21
- from md_processing import (extract_command, process_glossary_upsert_command, process_term_upsert_command,
22
- process_category_upsert_command, process_provenance_command, get_current_datetime_string,
23
- process_per_proj_upsert_command, command_list, process_blueprint_upsert_command,
24
- process_solution_component_upsert_command, process_component_link_unlink_command,
25
- process_term_list_command,
26
- process_category_list_command, process_glossary_list_command, process_term_history_command,
27
- process_glossary_structure_command, process_term_revision_history_command,
28
- process_create_term_term_relationship_command, process_term_details_command,
29
- process_information_supply_chain_upsert_command,
30
- process_information_supply_chain_link_unlink_command, process_sol_arch_list_command,
31
- process_digital_product_upsert_command, process_agreement_upsert_command,
32
- process_collection_upsert_command, process_link_agreement_item_command,
33
- process_gov_definition_upsert_command, GOV_COM_LIST, GOV_LINK_LIST,
34
- process_gov_def_link_detach_command,
35
- process_gov_def_context_command, process_supporting_gov_def_link_detach_command,
36
- process_attach_subscriber_command,
37
- COLLECTIONS_LIST, SIMPLE_COLLECTIONS, GOV_LINK_LIST, process_output_command)
38
- from md_processing.md_commands.data_designer_commands import (process_data_spec_upsert_command,
39
- process_data_dict_upsert_command,
40
- process_data_collection_list_command,
41
- process_data_structure_list_command,
42
- process_data_field_list_command,
43
- process_data_class_list_command,
44
- process_data_field_upsert_command,
45
- process_data_structure_upsert_command,
46
- process_data_class_upsert_command)
47
20
 
48
- from pyegeria import EgeriaTech, PyegeriaException, print_basic_exception, print_validation_error
21
+ from pyegeria._exceptions_new import PyegeriaException
22
+ from md_processing.dr_egeria import process_md_file
49
23
 
50
24
  EGERIA_METADATA_STORE = os.environ.get("EGERIA_METADATA_STORE", "active-metadata-store")
51
25
  EGERIA_KAFKA_ENDPOINT = os.environ.get("KAFKA_ENDPOINT", "localhost:9092")
@@ -66,7 +40,6 @@ EGERIA_ROOT_PATH = os.environ.get("EGERIA_ROOT_PATH", "../../")
66
40
  EGERIA_INBOX_PATH = os.environ.get("EGERIA_INBOX_PATH", "md_processing/dr_egeria_inbox")
67
41
  EGERIA_OUTBOX_PATH = os.environ.get("EGERIA_OUTBOX_PATH", "md_processing/dr_egeria_outbox")
68
42
 
69
- setup_log()
70
43
  @click.command("process_markdown_file", help="Process a markdown file and return the output as a string.")
71
44
  @click.option("--input-file", help="Markdown file to process.", default="dr_egeria_intro_part1.md", required=True,
72
45
  prompt=False)
@@ -79,242 +52,17 @@ setup_log()
79
52
  @click.option("--user_pass", default=EGERIA_USER_PASSWORD, help="Egeria user password")
80
53
  @logger.catch
81
54
  def process_markdown_file(input_file: str, output_folder:str, directive: str, server: str, url: str, userid: str,
82
- user_pass: str, ) -> None:
55
+ user_pass: str ) -> None:
83
56
  """
84
57
  Process a markdown file by parsing and executing Dr. Egeria md_commands. Write output to a new file.
85
58
  """
86
-
87
- cmd_list = command_list
88
- console = Console(width=int(EGERIA_WIDTH))
89
- client = EgeriaTech(server, url, user_id=userid)
90
- token = client.create_egeria_bearer_token(userid, user_pass)
91
-
92
- updated = False
93
- full_file_path = os.path.join(EGERIA_ROOT_PATH, EGERIA_INBOX_PATH, input_file)
94
- logger.info("\n\n====================================================\n\n")
95
- logger.info(f"Processing Markdown File: {full_file_path}")
96
59
  try:
97
- with open(full_file_path, 'r') as f:
98
- lines = f.readlines()
99
- except FileNotFoundError:
100
- print(f"Error: File not found at path: {full_file_path}")
101
- return {} # Return empty dict if file not found
102
-
103
- final_output = []
104
- prov_found = False
105
- prov_output = (f"\n# Provenance\n\n* Results from processing file {input_file} on "
106
- f"{datetime.now().strftime("%Y-%m-%d %H:%M")}\n")
107
- h1_blocks = []
108
- current_block = ""
109
- in_h1_block = False
110
-
111
- # Helper function to process the current block
112
- def process_current_block(current_block):
113
- nonlocal updated, final_output, prov_found, prov_output, h1_blocks, in_h1_block
114
-
115
- if not current_block:
116
- return # No block to process
117
-
118
- potential_command = extract_command(current_block) # Extract object_action
119
- if (potential_command in cmd_list):
120
- # Process the block based on the object_action
121
- if potential_command == "Provenance":
122
- result = process_provenance_command(input_file, current_block)
123
- prov_found = True
124
-
125
- elif potential_command in ["Create Glossary", "Update Glossary"]:
126
- result = process_glossary_upsert_command(client, current_block, directive)
127
- elif potential_command in ["Create Category", "Update Category"]:
128
- result = process_category_upsert_command(client, current_block, directive)
129
- elif potential_command in ["Create Term", "Update Term"]:
130
- result = process_term_upsert_command(client, current_block, directive)
131
- elif potential_command in ["Create Term-Term Relationship", "Update Term-Term Relationship"]:
132
- result = process_create_term_term_relationship_command(client, current_block, directive)
133
- elif potential_command in ["List Term History", "Term History"]:
134
- result = process_term_history_command(client, current_block, directive)
135
- elif potential_command in ["List Term Details"]:
136
- result = process_term_details_command(client, current_block, directive)
137
- elif potential_command in ["List Term Update History", "List Term Revision History"]:
138
- result = process_term_revision_history_command(client, current_block, directive)
139
- elif potential_command in ["List Terms", "List Glossary Terms"]:
140
- result = process_term_list_command(client, current_block, directive)
141
- elif potential_command in ["List Categories", "List Glossary Categories"]:
142
- result = process_category_list_command(client, current_block, directive)
143
- elif potential_command in ["List Glossary Structure"]:
144
- result = process_glossary_structure_command(client, current_block, directive)
145
- elif potential_command in ["List Glossaries"]:
146
- result = process_glossary_list_command(client, current_block, directive)
147
- elif potential_command in ["Create Personal Project", "Update Personal Project"]:
148
- result = process_per_proj_upsert_command(client, current_block, directive)
149
- elif potential_command in ["Create Blueprint", "Update Blueprint", "Create Solution Blueprint",
150
- "Update Solution Blueprint"]:
151
- result = process_blueprint_upsert_command(client, current_block, directive)
152
- elif potential_command in ["View Solution Blueprints", "View Blueprint", "View Solution Blueprint"]:
153
- result = process_sol_arch_list_command(client, current_block, "Solution Blueprints", directive)
154
- elif potential_command in ["View Solution Component", "View Solution Components"]:
155
- result = process_sol_arch_list_command(client, current_block, "Solution Components", directive)
156
- elif potential_command in ["View Solution Roles", "View Solution Role"]:
157
- result = process_sol_arch_list_command(client, current_block, "Solution Roles", directive)
158
- elif potential_command in ["View Information Supply Chain", "View Information Supply Chains"]:
159
- result = process_sol_arch_list_command(client, current_block, "Information Supply Chains", directive)
160
- elif potential_command in ["Create Solution Component", "Update Solution Component"]:
161
- result = process_solution_component_upsert_command(client, current_block, directive)
162
- elif potential_command in ["Link Solution Components", "Link Solution Component Peers", "Wire Solution Components",
163
- "Unlink Solution Components", "Detach Solution Components", "Detach Solution Component Peers"]:
164
- result = process_component_link_unlink_command(client, current_block, directive)
165
- elif potential_command in ["Create Information Supply Chain", "Update Information Supply Chain"]:
166
- result = process_information_supply_chain_upsert_command(client, current_block, directive)
167
-
168
- elif potential_command in ["Link Information Supply Chain Peers", "Link Information Supply Chains",
169
- "Link Supply Chains", "Unlink Information Supply Chain Peers",
170
- "Unlink Information Supply Chains", "Unlink Supply Chains"]:
171
- result = process_information_supply_chain_link_unlink_command(client, current_block, directive)
172
-
173
- elif potential_command in ["Create Data Spec", "Create Data Specification", "Update Data Spec",
174
- "Update Data Specification"]:
175
- result = process_data_spec_upsert_command(client, current_block, directive)
176
- elif potential_command in ["Create Data Dict", "Create Data Dictionary", "Update Data Spec",
177
- "Update Data Dictionary"]:
178
- result = process_data_dict_upsert_command(client, current_block, directive)
179
- elif potential_command in ["Create Data Field", "Update Data Field"]:
180
- result = process_data_field_upsert_command(client, current_block, directive)
181
- elif potential_command in ["Create Data Structure", "Update Data Structure"]:
182
- result = process_data_structure_upsert_command(client, current_block, directive)
183
- elif potential_command in ["Create Data Class", "Update Data Class"]:
184
- result = process_data_class_upsert_command(client, current_block, directive)
185
- elif potential_command in ["View Data Dictionaries", "View Data Dictionary", "View Data Specifications",
186
- "View Data Specs"]:
187
- result = process_data_collection_list_command(client, current_block, directive)
188
- elif potential_command in ["View Data Structures", "View Data Structure"]:
189
- result = process_data_structure_list_command(client, current_block, directive)
190
- elif potential_command in ["View Data Fields", "View Data Field"]:
191
- result = process_data_field_list_command(client, current_block, directive)
192
- elif potential_command in ["View Data Classes", "View Data Class"]:
193
- result = process_data_class_list_command(client, current_block, directive)
194
- elif potential_command in ["Create Digital Product", "Create Data Product","Update Digital Product", "Update Data Product"]:
195
- result = process_digital_product_upsert_command(client, current_block, directive)
196
- elif potential_command in ["Create Agreement", "Create Data Sharing Agreement", "Create Digital Subscription",
197
- "Create Product Subscription", "Update Agreement", "Update Data Sharing Agreement",
198
- "Update Digital Subscription", "Update Product Subscription"]:
199
- result = process_agreement_upsert_command(client, current_block, directive)
200
- elif potential_command in SIMPLE_COLLECTIONS:
201
- result = process_collection_upsert_command(client, current_block, directive)
202
- elif potential_command in GOV_COM_LIST:
203
- result = process_gov_definition_upsert_command(client, current_block, directive)
204
- elif potential_command in ['View Governance Definitions', 'List Governance Definitions',
205
- 'View Gov Definitions', 'List Gov Definitions']:
206
- result = process_gov_definition_list_command(client, current_block, directive)
207
- elif potential_command in GOV_LINK_LIST:
208
- result = process_gov_def_link_detach_command(client, current_block, directive)
209
- elif potential_command in ['Link Governance Mechanism', 'Detach Governance Mechanism',
210
- 'Link Governance Response', 'Detach Governance Response',]:
211
- result = process_supporting_gov_def_link_detach_command(client, current_block, directive)
212
- elif potential_command in ['Link Digital Products', 'Detach Digital Products',
213
- 'Link Product-Product', 'Detach Product-Product'
214
- ]:
215
- result = process_product_dependency_command(client, current_block, directive)
216
- elif potential_command in ['Link Agreement->Item', 'Detach Agreement->Item']:
217
- result = process_link_agreement_item_command(client, current_block, directive)
218
- elif potential_command in ['Link Collection->Resource', 'Detach Collection->Resource']:
219
- result = process_attach_collection_command(client, current_block, directive)
220
- elif potential_command in ['Link Member->Collection', 'Detach Member->Collection',]:
221
- result = process_add_to_collection_command(client, current_block, directive)
222
- elif potential_command in ['Link Subscriber->Subscription', 'Detach Subscriber->Subscription']:
223
- result = process_attach_subscriber_command(client, current_block, directive)
224
- elif potential_command in ['View Report']:
225
- result = process_output_command(client, current_block, directive)
226
-
227
- elif potential_command in COLLECTIONS_LIST:
228
- result = process_collection_list_command(client, current_block, directive)
229
-
230
-
231
-
232
- else:
233
- # If object_action is not recognized, keep the block as-is
234
- result = None
235
- print(f"\n===> Unknown command: {potential_command}")
236
- # print(json.dumps(dr_egeria_state.get_element_dictionary(), indent=4))
237
- if result:
238
- if directive == "process":
239
- updated = True
240
- final_output.append(result) # print(json.dumps(dr_egeria_state.get_element_dictionary(), indent=4))
241
- elif directive == "validate":
242
- pass # print(json.dumps(dr_egeria_state.get_element_dictionary(), indent=4))
243
- elif directive == "process":
244
- # Handle errors (skip this block but notify the user)
245
- print(f"\n==>\tErrors found while processing command: \'{potential_command}\'\n"
246
- f"\tPlease correct and try again. \n")
247
- final_output.append(current_block)
248
- final_output.append('\n___\n')
249
- else:
250
- # If there is no object_action, append the block as-is
251
- final_output.append(current_block)
252
-
253
- # Main parsing loop
254
- for line in lines:
255
- line = line.strip() # Remove leading/trailing whitespace
256
-
257
- # Handle a new H1 block (starting with `# `)
258
- if line.startswith("# "):
259
- if in_h1_block:
260
- # Process the current block before starting a new one
261
- process_current_block(current_block)
262
-
263
- # Start a new H1 block
264
- current_block = line
265
- in_h1_block = True
266
-
267
- # Handle the end of a block (line starts with `---`)
268
- elif line.startswith("___"):
269
- if in_h1_block:
270
- # Process the current block when it ends with `---`
271
- current_block += f"\n{line}"
272
- process_current_block(current_block)
273
- current_block = "" # Clear the block
274
- in_h1_block = False
275
-
276
- # Add lines to the current H1 block
277
- elif in_h1_block:
278
- current_block += f"\n{line}"
279
-
280
- # Append non-H1 content directly to the output
281
- else:
282
- final_output.append(line)
283
-
284
- # Ensure the final H1 block is processed if the file doesn't end with `---`
285
- if in_h1_block:
286
- process_current_block(current_block)
287
-
288
- # Join the final output list into a single string
289
- final_output = "\n".join(final_output)
290
-
291
- try:
292
- if updated:
293
- path, filename = os.path.split(input_file) # Get both parts
294
- new_filename = f"processed-{get_current_datetime_string()}-{filename}" # Create the new filename
295
-
296
- if output_folder:
297
- new_file_path = os.path.join(EGERIA_ROOT_PATH, EGERIA_OUTBOX_PATH, output_folder, new_filename)
298
- else:
299
- new_file_path = os.path.join(EGERIA_ROOT_PATH, EGERIA_OUTBOX_PATH, new_filename)
300
- os.makedirs(os.path.dirname(new_file_path), exist_ok=True)
301
-
302
- with open(new_file_path, 'w') as f2:
303
- f2.write(final_output)
304
- if not prov_found:
305
- f2.write(prov_output)
306
- click.echo(f"\n==> Output written to {new_file_path}")
307
- else:
308
- if directive != 'display':
309
- click.echo("\nNo updates detected. New File not created.")
310
- logger.error("===> Unknown Command? <===")
311
-
60
+ process_md_file(input_file, output_folder, directive, server, url, userid, user_pass)
61
+ logger.info(f"Called process_markdown_file with input file {input_file}")
312
62
  except PyegeriaException as e:
313
- print_basic_exception(e)
314
- except ValidationError as e:
315
- print_validation_error(e)
316
- except (Exception):
317
- console.print_exception(show_locals=True)
63
+ logger.error(f"Error processing markdown file {input_file}: {e}")
64
+ except Exception as e:
65
+ logger.error(f"Unexpected error processing markdown file {input_file}: {e}")
318
66
 
319
67
 
320
68
  # def main():
md_processing/__init__.py CHANGED
@@ -47,7 +47,7 @@ from md_processing.md_commands.project_commands import (process_per_proj_upsert_
47
47
  # Re-export all functions from the original md_processing_utils.py to maintain backward compatibility
48
48
  from md_processing.md_processing_utils.common_md_utils import (render_markdown, is_valid_iso_date, set_debug_level,
49
49
  get_current_datetime_string, print_msg, EGERIA_WIDTH,
50
- console, debug_level, get_element_dictionary,
50
+ debug_level, get_element_dictionary,
51
51
  update_element_dictionary, clear_element_dictionary,
52
52
  is_present, find_key_with_value,
53
53
  process_provenance_command, set_delete_request_body,
@@ -78,4 +78,4 @@ from md_processing.md_processing_utils.md_processing_constants import (load_comm
78
78
  # Import message constants
79
79
  from md_processing.md_processing_utils.message_constants import (message_types, ALWAYS, ERROR, INFO, WARNING)
80
80
 
81
- from md_processing.md_processing_utils.common_md_proc_utils import process_output_command
81
+ from md_processing.md_processing_utils.common_md_proc_utils import process_output_command
@@ -0,0 +1,309 @@
1
+ """
2
+ This is an ongoing experiment in parsing and playing with Freddie docs
3
+ """
4
+ import os
5
+ import sys
6
+ from datetime import datetime
7
+
8
+ from loguru import logger
9
+ from pydantic import ValidationError
10
+
11
+ log_format = "{time} | {level} | {function} | {line} | {message} | {extra}"
12
+ logger.remove()
13
+ logger.add(sys.stderr, level="INFO", format=log_format, colorize=True)
14
+ logger.add("debug_log.log", rotation="1 day", retention="1 week", compression="zip", level="TRACE", format=log_format,
15
+ colorize=True)
16
+
17
+ from rich import print
18
+ from rich.console import Console
19
+
20
+ from md_processing import (extract_command, process_glossary_upsert_command, process_term_upsert_command,
21
+ process_category_upsert_command, process_provenance_command, get_current_datetime_string,
22
+ process_per_proj_upsert_command, command_list, process_blueprint_upsert_command,
23
+ process_solution_component_upsert_command, process_component_link_unlink_command,
24
+ process_term_list_command,
25
+ process_category_list_command, process_glossary_list_command, process_term_history_command,
26
+ process_glossary_structure_command, process_term_revision_history_command,
27
+ process_create_term_term_relationship_command, process_term_details_command,
28
+ process_information_supply_chain_upsert_command,
29
+ process_information_supply_chain_link_unlink_command, process_sol_arch_list_command,
30
+ process_digital_product_upsert_command, process_agreement_upsert_command,
31
+ process_collection_upsert_command, process_link_agreement_item_command,
32
+ process_gov_definition_upsert_command, GOV_COM_LIST, GOV_LINK_LIST,
33
+ process_gov_def_link_detach_command, process_product_dependency_command,
34
+ process_add_to_collection_command, process_attach_collection_command,
35
+ # process_collection_list_command, process_gov_definition_list_command,
36
+ process_gov_def_context_command, process_supporting_gov_def_link_detach_command,
37
+ process_attach_subscriber_command,
38
+ COLLECTIONS_LIST, SIMPLE_COLLECTIONS, GOV_LINK_LIST, process_output_command)
39
+ from .md_commands.data_designer_commands import (process_data_spec_upsert_command,
40
+ process_data_dict_upsert_command,
41
+ process_data_collection_list_command,
42
+ process_data_structure_list_command,
43
+ process_data_field_list_command,
44
+ process_data_class_list_command,
45
+ process_data_field_upsert_command,
46
+ process_data_structure_upsert_command,
47
+ process_data_class_upsert_command)
48
+
49
+ from pyegeria import EgeriaTech, PyegeriaException, print_basic_exception, print_validation_error
50
+
51
+ EGERIA_METADATA_STORE = os.environ.get("EGERIA_METADATA_STORE", "active-metadata-store")
52
+ EGERIA_KAFKA_ENDPOINT = os.environ.get("KAFKA_ENDPOINT", "localhost:9092")
53
+ EGERIA_PLATFORM_URL = os.environ.get("EGERIA_PLATFORM_URL", "https://localhost:9443")
54
+ EGERIA_VIEW_SERVER = os.environ.get("EGERIA_VIEW_SERVER", "view-server")
55
+ EGERIA_VIEW_SERVER_URL = os.environ.get("EGERIA_VIEW_SERVER_URL", "https://localhost:9443")
56
+ EGERIA_INTEGRATION_DAEMON = os.environ.get("EGERIA_INTEGRATION_DAEMON", "integration-daemon")
57
+ EGERIA_INTEGRATION_DAEMON_URL = os.environ.get("EGERIA_INTEGRATION_DAEMON_URL", "https://localhost:9443")
58
+ EGERIA_ADMIN_USER = os.environ.get("ADMIN_USER", "garygeeke")
59
+ EGERIA_ADMIN_PASSWORD = os.environ.get("ADMIN_PASSWORD", "secret")
60
+ EGERIA_USER = os.environ.get("EGERIA_USER", "erinoverview")
61
+ EGERIA_USER_PASSWORD = os.environ.get("EGERIA_USER_PASSWORD", "secret")
62
+ EGERIA_WIDTH = os.environ.get("EGERIA_WIDTH", 220)
63
+ EGERIA_JUPYTER = os.environ.get("EGERIA_JUPYTER", False)
64
+ EGERIA_HOME_GLOSSARY_GUID = os.environ.get("EGERIA_HOME_GLOSSARY_GUID", None)
65
+ EGERIA_GLOSSARY_PATH = os.environ.get("EGERIA_GLOSSARY_PATH", None)
66
+ EGERIA_ROOT_PATH = os.environ.get("EGERIA_ROOT_PATH", "../../")
67
+ EGERIA_INBOX_PATH = os.environ.get("EGERIA_INBOX_PATH", "md_processing/dr_egeria_inbox")
68
+ EGERIA_OUTBOX_PATH = os.environ.get("EGERIA_OUTBOX_PATH", "md_processing/dr_egeria_outbox")
69
+
70
+
71
+ @logger.catch
72
+ def process_md_file(input_file: str, output_folder:str, directive: str, server: str, url: str, userid: str,
73
+ user_pass: str ) -> None:
74
+ """
75
+ Process a markdown file by parsing and executing Dr. Egeria md_commands. Write output to a new file.
76
+ """
77
+
78
+ cmd_list = command_list
79
+ console = Console(width=int(EGERIA_WIDTH))
80
+ client = EgeriaTech(server, url, user_id=userid)
81
+ token = client.create_egeria_bearer_token(userid, user_pass)
82
+
83
+ updated = False
84
+ full_file_path = os.path.join(EGERIA_ROOT_PATH, EGERIA_INBOX_PATH, input_file)
85
+ logger.info("\n\n====================================================\n\n")
86
+ logger.info(f"Processing Markdown File: {full_file_path}")
87
+ try:
88
+ with open(full_file_path, 'r') as f:
89
+ lines = f.readlines()
90
+ except FileNotFoundError:
91
+ print(f"Error: File not found at path: {full_file_path}")
92
+ return {} # Return empty dict if file not found
93
+
94
+ final_output = []
95
+ prov_found = False
96
+ prov_output = (f"\n# Provenance\n\n* Results from processing file {input_file} on "
97
+ f"{datetime.now().strftime("%Y-%m-%d %H:%M")}\n")
98
+ h1_blocks = []
99
+ current_block = ""
100
+ in_h1_block = False
101
+
102
+ # Helper function to process the current block
103
+ def process_current_block(current_block):
104
+ nonlocal updated, final_output, prov_found, prov_output, h1_blocks, in_h1_block
105
+
106
+ if not current_block:
107
+ return # No block to process
108
+
109
+ potential_command = extract_command(current_block) # Extract object_action
110
+ if (potential_command in cmd_list):
111
+ # Process the block based on the object_action
112
+ if potential_command == "Provenance":
113
+ result = process_provenance_command(input_file, current_block)
114
+ prov_found = True
115
+
116
+ elif potential_command in ["Create Glossary", "Update Glossary"]:
117
+ result = process_glossary_upsert_command(client, current_block, directive)
118
+ elif potential_command in ["Create Category", "Update Category"]:
119
+ result = process_category_upsert_command(client, current_block, directive)
120
+ elif potential_command in ["Create Term", "Update Term"]:
121
+ result = process_term_upsert_command(client, current_block, directive)
122
+ elif potential_command in ["Create Term-Term Relationship", "Update Term-Term Relationship"]:
123
+ result = process_create_term_term_relationship_command(client, current_block, directive)
124
+ elif potential_command in ["List Term History", "Term History"]:
125
+ result = process_term_history_command(client, current_block, directive)
126
+ elif potential_command in ["List Term Details"]:
127
+ result = process_term_details_command(client, current_block, directive)
128
+ elif potential_command in ["List Term Update History", "List Term Revision History"]:
129
+ result = process_term_revision_history_command(client, current_block, directive)
130
+ elif potential_command in ["List Terms", "List Glossary Terms"]:
131
+ result = process_term_list_command(client, current_block, directive)
132
+ elif potential_command in ["List Categories", "List Glossary Categories"]:
133
+ result = process_category_list_command(client, current_block, directive)
134
+ elif potential_command in ["List Glossary Structure"]:
135
+ result = process_glossary_structure_command(client, current_block, directive)
136
+ elif potential_command in ["List Glossaries"]:
137
+ result = process_glossary_list_command(client, current_block, directive)
138
+ elif potential_command in ["Create Personal Project", "Update Personal Project"]:
139
+ result = process_per_proj_upsert_command(client, current_block, directive)
140
+ elif potential_command in ["Create Blueprint", "Update Blueprint", "Create Solution Blueprint",
141
+ "Update Solution Blueprint"]:
142
+ result = process_blueprint_upsert_command(client, current_block, directive)
143
+ elif potential_command in ["View Solution Blueprints", "View Blueprint", "View Solution Blueprint"]:
144
+ result = process_sol_arch_list_command(client, current_block, "Solution Blueprints", directive)
145
+ elif potential_command in ["View Solution Component", "View Solution Components"]:
146
+ result = process_sol_arch_list_command(client, current_block, "Solution Components", directive)
147
+ elif potential_command in ["View Solution Roles", "View Solution Role"]:
148
+ result = process_sol_arch_list_command(client, current_block, "Solution Roles", directive)
149
+ elif potential_command in ["View Information Supply Chain", "View Information Supply Chains"]:
150
+ result = process_sol_arch_list_command(client, current_block, "Information Supply Chains", directive)
151
+ elif potential_command in ["Create Solution Component", "Update Solution Component"]:
152
+ result = process_solution_component_upsert_command(client, current_block, directive)
153
+ elif potential_command in ["Link Solution Components", "Link Solution Component Peers", "Wire Solution Components",
154
+ "Unlink Solution Components", "Detach Solution Components", "Detach Solution Component Peers"]:
155
+ result = process_component_link_unlink_command(client, current_block, directive)
156
+ elif potential_command in ["Create Information Supply Chain", "Update Information Supply Chain"]:
157
+ result = process_information_supply_chain_upsert_command(client, current_block, directive)
158
+
159
+ elif potential_command in ["Link Information Supply Chain Peers", "Link Information Supply Chains",
160
+ "Link Supply Chains", "Unlink Information Supply Chain Peers",
161
+ "Unlink Information Supply Chains", "Unlink Supply Chains"]:
162
+ result = process_information_supply_chain_link_unlink_command(client, current_block, directive)
163
+
164
+ elif potential_command in ["Create Data Spec", "Create Data Specification", "Update Data Spec",
165
+ "Update Data Specification"]:
166
+ result = process_data_spec_upsert_command(client, current_block, directive)
167
+ elif potential_command in ["Create Data Dict", "Create Data Dictionary", "Update Data Spec",
168
+ "Update Data Dictionary"]:
169
+ result = process_data_dict_upsert_command(client, current_block, directive)
170
+ elif potential_command in ["Create Data Field", "Update Data Field"]:
171
+ result = process_data_field_upsert_command(client, current_block, directive)
172
+ elif potential_command in ["Create Data Structure", "Update Data Structure"]:
173
+ result = process_data_structure_upsert_command(client, current_block, directive)
174
+ elif potential_command in ["Create Data Class", "Update Data Class"]:
175
+ result = process_data_class_upsert_command(client, current_block, directive)
176
+ elif potential_command in ["View Data Dictionaries", "View Data Dictionary", "View Data Specifications",
177
+ "View Data Specs"]:
178
+ result = process_data_collection_list_command(client, current_block, directive)
179
+ elif potential_command in ["View Data Structures", "View Data Structure"]:
180
+ result = process_data_structure_list_command(client, current_block, directive)
181
+ elif potential_command in ["View Data Fields", "View Data Field"]:
182
+ result = process_data_field_list_command(client, current_block, directive)
183
+ elif potential_command in ["View Data Classes", "View Data Class"]:
184
+ result = process_data_class_list_command(client, current_block, directive)
185
+ elif potential_command in ["Create Digital Product", "Create Data Product","Update Digital Product", "Update Data Product"]:
186
+ result = process_digital_product_upsert_command(client, current_block, directive)
187
+ elif potential_command in ["Create Agreement", "Create Data Sharing Agreement", "Create Digital Subscription",
188
+ "Create Product Subscription", "Update Agreement", "Update Data Sharing Agreement",
189
+ "Update Digital Subscription", "Update Product Subscription"]:
190
+ result = process_agreement_upsert_command(client, current_block, directive)
191
+ elif potential_command in SIMPLE_COLLECTIONS:
192
+ result = process_collection_upsert_command(client, current_block, directive)
193
+ elif potential_command in GOV_COM_LIST:
194
+ result = process_gov_definition_upsert_command(client, current_block, directive)
195
+ # elif potential_command in ['View Governance Definitions', 'List Governance Definitions',
196
+ # 'View Gov Definitions', 'List Gov Definitions']:
197
+ # result = process_gov_definition_list_command(client, current_block, directive)
198
+ elif potential_command in GOV_LINK_LIST:
199
+ result = process_gov_def_link_detach_command(client, current_block, directive)
200
+ elif potential_command in ['Link Governance Mechanism', 'Detach Governance Mechanism',
201
+ 'Link Governance Response', 'Detach Governance Response',]:
202
+ result = process_supporting_gov_def_link_detach_command(client, current_block, directive)
203
+ elif potential_command in ['Link Digital Products', 'Detach Digital Products',
204
+ 'Link Product-Product', 'Detach Product-Product'
205
+ ]:
206
+ result = process_product_dependency_command(client, current_block, directive)
207
+ elif potential_command in ['Link Agreement->Item', 'Detach Agreement->Item']:
208
+ result = process_link_agreement_item_command(client, current_block, directive)
209
+ elif potential_command in ['Link Collection->Resource', 'Detach Collection->Resource']:
210
+ result = process_attach_collection_command(client, current_block, directive)
211
+ elif potential_command in ['Link Member->Collection', 'Detach Member->Collection',]:
212
+ result = process_add_to_collection_command(client, current_block, directive)
213
+ elif potential_command in ['Link Subscriber->Subscription', 'Detach Subscriber->Subscription']:
214
+ result = process_attach_subscriber_command(client, current_block, directive)
215
+ elif potential_command in ['View Report']:
216
+ result = process_output_command(client, current_block, directive)
217
+
218
+ # elif potential_command in COLLECTIONS_LIST:
219
+ # result = process_collection_list_command(client, current_block, directive)
220
+
221
+
222
+
223
+ else:
224
+ # If object_action is not recognized, keep the block as-is
225
+ result = None
226
+ print(f"\n===> Unknown command: {potential_command}")
227
+ # print(json.dumps(dr_egeria_state.get_element_dictionary(), indent=4))
228
+ if result:
229
+ if directive == "process":
230
+ updated = True
231
+ final_output.append(result) # print(json.dumps(dr_egeria_state.get_element_dictionary(), indent=4))
232
+ elif directive == "validate":
233
+ pass # print(json.dumps(dr_egeria_state.get_element_dictionary(), indent=4))
234
+ elif directive == "process":
235
+ # Handle errors (skip this block but notify the user)
236
+ print(f"\n==>\tErrors found while processing command: \'{potential_command}\'\n"
237
+ f"\tPlease correct and try again. \n")
238
+ final_output.append(current_block)
239
+ final_output.append('\n___\n')
240
+ else:
241
+ # If there is no object_action, append the block as-is
242
+ final_output.append(current_block)
243
+
244
+ # Main parsing loop
245
+ for line in lines:
246
+ line = line.strip() # Remove leading/trailing whitespace
247
+
248
+ # Handle a new H1 block (starting with `# `)
249
+ if line.startswith("# "):
250
+ if in_h1_block:
251
+ # Process the current block before starting a new one
252
+ process_current_block(current_block)
253
+
254
+ # Start a new H1 block
255
+ current_block = line
256
+ in_h1_block = True
257
+
258
+ # Handle the end of a block (line starts with `---`)
259
+ elif line.startswith("___"):
260
+ if in_h1_block:
261
+ # Process the current block when it ends with `---`
262
+ current_block += f"\n{line}"
263
+ process_current_block(current_block)
264
+ current_block = "" # Clear the block
265
+ in_h1_block = False
266
+
267
+ # Add lines to the current H1 block
268
+ elif in_h1_block:
269
+ current_block += f"\n{line}"
270
+
271
+ # Append non-H1 content directly to the output
272
+ else:
273
+ final_output.append(line)
274
+
275
+ # Ensure the final H1 block is processed if the file doesn't end with `---`
276
+ if in_h1_block:
277
+ process_current_block(current_block)
278
+
279
+ # Join the final output list into a single string
280
+ final_output = "\n".join(final_output)
281
+
282
+ try:
283
+ if updated:
284
+ path, filename = os.path.split(input_file) # Get both parts
285
+ new_filename = f"processed-{get_current_datetime_string()}-{filename}" # Create the new filename
286
+
287
+ if output_folder:
288
+ new_file_path = os.path.join(EGERIA_ROOT_PATH, EGERIA_OUTBOX_PATH, output_folder, new_filename)
289
+ else:
290
+ new_file_path = os.path.join(EGERIA_ROOT_PATH, EGERIA_OUTBOX_PATH, new_filename)
291
+ os.makedirs(os.path.dirname(new_file_path), exist_ok=True)
292
+
293
+ with open(new_file_path, 'w') as f2:
294
+ f2.write(final_output)
295
+ if not prov_found:
296
+ f2.write(prov_output)
297
+ print(f"\n==> Output written to {new_file_path}")
298
+ else:
299
+ if directive != 'display':
300
+ print("\nNo updates detected. New File not created.")
301
+ logger.error("===> Unknown Command? <===")
302
+
303
+ except PyegeriaException as e:
304
+ print_basic_exception(e)
305
+ except ValidationError as e:
306
+ print_validation_error(e)
307
+ except (Exception):
308
+ console.print_exception(show_locals=True)
309
+
@@ -12,7 +12,7 @@ from rich.console import Console
12
12
  from rich.markdown import Markdown
13
13
 
14
14
  from md_processing.md_processing_utils.common_md_proc_utils import (parse_upsert_command, parse_view_command)
15
- from md_processing.md_processing_utils.common_md_utils import update_element_dictionary, setup_log
15
+ from md_processing.md_processing_utils.common_md_utils import update_element_dictionary
16
16
  from md_processing.md_processing_utils.extraction_utils import (extract_command_plus, update_a_command)
17
17
  from md_processing.md_processing_utils.md_processing_constants import (load_commands, ERROR)
18
18
  from pyegeria import DEBUG_LEVEL, body_slimmer
@@ -41,7 +41,6 @@ load_commands('commands.json')
41
41
  debug_level = DEBUG_LEVEL
42
42
 
43
43
  console = Console(width=int(200))
44
- setup_log()
45
44
 
46
45
 
47
46
  #