pyegeria 5.3.4.27__py3-none-any.whl → 5.3.5.2__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 +1 -0
- pyegeria/_globals.py +2 -1
- pyegeria/asset_catalog_omvs.py +67 -11
- pyegeria/commands/cat/freddie_jupyter.py +124 -0
- pyegeria/commands/cat/freddie_md.py +158 -0
- pyegeria/commands/cat/freddie_utils.py +530 -0
- pyegeria/commands/cat/glossary_actions.py +112 -12
- pyegeria/commands/cli/egeria.py +4 -4
- pyegeria/commands/cli/egeria_cat.py +4 -4
- pyegeria/glossary_browser_omvs.py +2 -2
- pyegeria/glossary_manager_omvs.py +779 -570
- pyegeria/project_manager_omvs.py +2 -2
- {pyegeria-5.3.4.27.dist-info → pyegeria-5.3.5.2.dist-info}/METADATA +2 -1
- {pyegeria-5.3.4.27.dist-info → pyegeria-5.3.5.2.dist-info}/RECORD +17 -14
- {pyegeria-5.3.4.27.dist-info → pyegeria-5.3.5.2.dist-info}/entry_points.txt +5 -2
- {pyegeria-5.3.4.27.dist-info → pyegeria-5.3.5.2.dist-info}/LICENSE +0 -0
- {pyegeria-5.3.4.27.dist-info → pyegeria-5.3.5.2.dist-info}/WHEEL +0 -0
pyegeria/__init__.py
CHANGED
pyegeria/_globals.py
CHANGED
@@ -42,4 +42,5 @@ NO_CATALOGS_FOUND = "No catalogs found"
|
|
42
42
|
NO_GLOSSARIES_FOUND = "No glossaries found"
|
43
43
|
NO_TERMS_FOUND = "No terms found"
|
44
44
|
NO_CATEGORIES_FOUND = "No categories found"
|
45
|
-
NO_ELEMENT_FOUND = "No element found"
|
45
|
+
NO_ELEMENT_FOUND = "No element found"
|
46
|
+
NO_PROJECTS_FOUND = "No projects found"
|
pyegeria/asset_catalog_omvs.py
CHANGED
@@ -544,6 +544,11 @@ class AssetCatalog(Client):
|
|
544
544
|
async def _async_get_asset_lineage_graph(
|
545
545
|
self,
|
546
546
|
asset_guid: str,
|
547
|
+
effective_time: str = None,
|
548
|
+
as_of_time: str = None,
|
549
|
+
relationship_types: [str] = None,
|
550
|
+
limit_to_isc_q_name: str = None,
|
551
|
+
hilight_isc_q_name: str = None,
|
547
552
|
start_from: int = 0,
|
548
553
|
page_size: int = max_paging_size,
|
549
554
|
) -> str | dict:
|
@@ -552,6 +557,16 @@ class AssetCatalog(Client):
|
|
552
557
|
----------
|
553
558
|
asset_guid : str
|
554
559
|
The unique identity of the asset to get the graph for.
|
560
|
+
effective_time: str, default is None
|
561
|
+
Effective time to query on. If not specified, the current time is used.
|
562
|
+
as_of_time: str = None
|
563
|
+
as_of_time to query on. If not specified, the current time is used.
|
564
|
+
relationship_types: [str], default is None,
|
565
|
+
relationship types to include in the lineage graph. If not specified, all relationship types are included.
|
566
|
+
limit_to_isc_q_name: str = None,
|
567
|
+
if specified, filters results to only include information supply chains with the given name.
|
568
|
+
hilight_isc_q_name: str = None,
|
569
|
+
if speficied, highlights the information supply chain with the given name.
|
555
570
|
|
556
571
|
start_from : int, optional
|
557
572
|
The index from which to start fetching the engine actions. Default is 0.
|
@@ -576,27 +591,48 @@ class AssetCatalog(Client):
|
|
576
591
|
f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/asset-catalog/assets/{asset_guid}/"
|
577
592
|
f"as-lineage-graph?startFrom={start_from}&pageSize={page_size}"
|
578
593
|
)
|
579
|
-
|
580
|
-
|
594
|
+
body = {
|
595
|
+
"effectiveTime": effective_time,
|
596
|
+
"asOfTime": as_of_time,
|
597
|
+
"relationshipTypes": relationship_types,
|
598
|
+
"limitToISCQName": limit_to_isc_q_name,
|
599
|
+
"hilightISCQName": hilight_isc_q_name,
|
600
|
+
}
|
601
|
+
response = await self._async_make_request("POST", url, body_slimmer(body))
|
581
602
|
return response.json().get("assetLineageGraph", NO_ASSETS_FOUND)
|
582
603
|
|
583
604
|
def get_asset_lineage_graph(
|
584
605
|
self,
|
585
606
|
asset_guid: str,
|
607
|
+
effective_time: str = None,
|
608
|
+
as_of_time: str = None,
|
609
|
+
relationship_types: [str] = None,
|
610
|
+
limit_to_isc_q_name: str = None,
|
611
|
+
hilight_isc_q_name: str = None,
|
586
612
|
start_from: int = 0,
|
587
613
|
page_size: int = max_paging_size,
|
588
|
-
|
614
|
+
) -> str | dict:
|
589
615
|
"""Return the asset lineage including a mermaid markdown string. Async Version.
|
590
616
|
Parameters
|
591
617
|
----------
|
592
618
|
asset_guid : str
|
593
619
|
The unique identity of the asset to get the graph for.
|
620
|
+
effective_time: str, default is None
|
621
|
+
Effective time to query on. If not specified, the current time is used.
|
622
|
+
as_of_time: str = None
|
623
|
+
as_of_time to query on. If not specified, the current time is used.
|
624
|
+
relationship_types: [str], default is None,
|
625
|
+
relationship types to include in the lineage graph. If not specified, all relationship types are included.
|
626
|
+
limit_to_isc_q_name: str = None,
|
627
|
+
if specified, filters results to only include information supply chains with the given name.
|
628
|
+
hilight_isc_q_name: str = None,
|
629
|
+
if speficied, highlights the information supply chain with the given name.
|
594
630
|
|
595
631
|
start_from : int, optional
|
596
632
|
The index from which to start fetching the engine actions. Default is 0.
|
597
633
|
|
598
634
|
page_size : int, optional
|
599
|
-
The maximum number of
|
635
|
+
The maximum number of elements to fetch in a single request. Default is `max_paging_size`.
|
600
636
|
|
601
637
|
Returns
|
602
638
|
-------
|
@@ -613,29 +649,46 @@ class AssetCatalog(Client):
|
|
613
649
|
|
614
650
|
loop = asyncio.get_event_loop()
|
615
651
|
response = loop.run_until_complete(
|
616
|
-
self._async_get_asset_lineage_graph(asset_guid,
|
652
|
+
self._async_get_asset_lineage_graph(asset_guid, effective_time, as_of_time, relationship_types,
|
653
|
+
limit_to_isc_q_name, hilight_isc_q_name, start_from, page_size)
|
617
654
|
)
|
618
655
|
return response
|
619
656
|
|
620
657
|
def get_asset_lineage_mermaid_graph(
|
621
658
|
self,
|
622
659
|
asset_guid: str,
|
660
|
+
effective_time: str = None,
|
661
|
+
as_of_time: str = None,
|
662
|
+
relationship_types: [str] = None,
|
663
|
+
limit_to_isc_q_name: str = None,
|
664
|
+
hilight_isc_q_name: str = None,
|
623
665
|
start_from: int = 0,
|
624
666
|
page_size: int = max_paging_size,
|
625
|
-
|
626
|
-
"""Return the lineage
|
667
|
+
) -> str:
|
668
|
+
"""Return the asset lineage including a mermaid markdown string. Async Version.
|
627
669
|
Parameters
|
628
670
|
----------
|
629
671
|
asset_guid : str
|
630
672
|
The unique identity of the asset to get the graph for.
|
673
|
+
effective_time: str, default is None
|
674
|
+
Effective time to query on. If not specified, the current time is used.
|
675
|
+
as_of_time: str = None
|
676
|
+
as_of_time to query on. If not specified, the current time is used.
|
677
|
+
relationship_types: [str], default is None,
|
678
|
+
relationship types to include in the lineage graph. If not specified, all relationship types are included.
|
679
|
+
limit_to_isc_q_name: str = None,
|
680
|
+
if specified, filters results to only include information supply chains with the given name.
|
681
|
+
hilight_isc_q_name: str = None,
|
682
|
+
if specified, highlights the information supply chain with the given name.
|
631
683
|
|
632
684
|
start_from : int, optional
|
633
685
|
The index from which to start fetching the engine actions. Default is 0.
|
634
686
|
|
635
687
|
page_size : int, optional
|
636
|
-
The maximum number of
|
688
|
+
The maximum number of elements to fetch in a single request.
|
689
|
+
Default is `max_paging_size`.
|
637
690
|
|
638
|
-
|
691
|
+
Returns
|
639
692
|
-------
|
640
693
|
str
|
641
694
|
A mermaid string representing the lineage.
|
@@ -646,9 +699,12 @@ class AssetCatalog(Client):
|
|
646
699
|
PropertyServerException
|
647
700
|
UserNotAuthorizedException
|
648
701
|
|
649
|
-
|
702
|
+
"""
|
650
703
|
|
651
|
-
asset_graph = self.get_asset_lineage_graph(asset_guid,
|
704
|
+
asset_graph = self.get_asset_lineage_graph(asset_guid, effective_time,
|
705
|
+
as_of_time, relationship_types,
|
706
|
+
limit_to_isc_q_name, hilight_isc_q_name,
|
707
|
+
start_from, page_size)
|
652
708
|
return asset_graph.get("mermaidGraph")
|
653
709
|
|
654
710
|
async def _async_get_assets_by_metadata_collection_id(
|
@@ -0,0 +1,124 @@
|
|
1
|
+
"""
|
2
|
+
This is an ongoing experiment in parsing and playing with Freddie docs
|
3
|
+
"""
|
4
|
+
import json
|
5
|
+
|
6
|
+
from jupyter_notebook_parser import JupyterNotebookParser
|
7
|
+
import nbformat
|
8
|
+
import os
|
9
|
+
import re
|
10
|
+
from pyegeria import EgeriaTech
|
11
|
+
from rich import box, print
|
12
|
+
from rich.console import Console
|
13
|
+
from rich.markdown import Markdown
|
14
|
+
from rich.prompt import Prompt
|
15
|
+
from rich.table import Table
|
16
|
+
from freddie_utils import (extract_command, process_glossary_upsert_command, process_term_upsert_command,
|
17
|
+
get_current_datetime_string)
|
18
|
+
|
19
|
+
import click
|
20
|
+
from pyegeria import EgeriaTech, body_slimmer, NO_GLOSSARIES_FOUND, NO_TERMS_FOUND, NO_ELEMENTS_FOUND
|
21
|
+
from pyegeria._exceptions import (
|
22
|
+
InvalidParameterException,
|
23
|
+
PropertyServerException,
|
24
|
+
print_exception_response,
|
25
|
+
)
|
26
|
+
import datetime
|
27
|
+
|
28
|
+
EGERIA_METADATA_STORE = os.environ.get("EGERIA_METADATA_STORE", "active-metadata-store")
|
29
|
+
EGERIA_KAFKA_ENDPOINT = os.environ.get("KAFKA_ENDPOINT", "localhost:9092")
|
30
|
+
EGERIA_PLATFORM_URL = os.environ.get("EGERIA_PLATFORM_URL", "https://localhost:9443")
|
31
|
+
EGERIA_VIEW_SERVER = os.environ.get("EGERIA_VIEW_SERVER", "view-server")
|
32
|
+
EGERIA_VIEW_SERVER_URL = os.environ.get(
|
33
|
+
"EGERIA_VIEW_SERVER_URL", "https://localhost:9443"
|
34
|
+
)
|
35
|
+
EGERIA_INTEGRATION_DAEMON = os.environ.get("EGERIA_INTEGRATION_DAEMON", "integration-daemon")
|
36
|
+
EGERIA_INTEGRATION_DAEMON_URL = os.environ.get(
|
37
|
+
"EGERIA_INTEGRATION_DAEMON_URL", "https://localhost:9443"
|
38
|
+
)
|
39
|
+
EGERIA_ADMIN_USER = os.environ.get("ADMIN_USER", "garygeeke")
|
40
|
+
EGERIA_ADMIN_PASSWORD = os.environ.get("ADMIN_PASSWORD", "secret")
|
41
|
+
EGERIA_USER = os.environ.get("EGERIA_USER", "erinoverview")
|
42
|
+
EGERIA_USER_PASSWORD = os.environ.get("EGERIA_USER_PASSWORD", "secret")
|
43
|
+
EGERIA_WIDTH = os.environ.get("EGERIA_WIDTH", 220)
|
44
|
+
EGERIA_JUPYTER = os.environ.get("EGERIA_JUPYTER", False)
|
45
|
+
EGERIA_HOME_GLOSSARY_GUID = os.environ.get("EGERIA_HOME_GLOSSARY_GUID", None)
|
46
|
+
EGERIA_GLOSSARY_PATH = os.environ.get("EGERIA_GLOSSARY_PATH", None)
|
47
|
+
EGERIA_ROOT_PATH = os.environ.get("EGERIA_ROOT_PATH", "/Users/dwolfson/localGit/egeria-v5-3/egeria-workspaces")
|
48
|
+
EGERIA_FREDDIE_INBOX_PATH = os.environ.get("EGERIA_FREDDIE_INBOX_PATH", "exchange/loading-bay/freddies-inbox")
|
49
|
+
EGERIA_FREDDIE_OUTBOX_PATH = os.environ.get("EGERIA_FREDDIE_OUTBOX_PATH", "exchange/distribution-hub/freddies-outbox")
|
50
|
+
commands = ["Create Glossary", "Create Term", "Create Governance Definition", "Update Term"]
|
51
|
+
console = Console(width=int(EGERIA_WIDTH))
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
@click.command("process-jupyter")
|
56
|
+
@click.option("--file-path", help="File path to notebook",
|
57
|
+
default="glossary_creation_experiment.ipynb")
|
58
|
+
@click.option("--directive", default="display-only", help="How to process the file")
|
59
|
+
@click.option("--server", default=EGERIA_VIEW_SERVER, help="Egeria view server to use.")
|
60
|
+
@click.option(
|
61
|
+
"--url", default=EGERIA_VIEW_SERVER_URL, help="URL of Egeria platform to connect to"
|
62
|
+
)
|
63
|
+
@click.option("--userid", default=EGERIA_USER, help="Egeria user")
|
64
|
+
@click.option("--user_pass", default=EGERIA_USER_PASSWORD, help="Egeria user password")
|
65
|
+
def process_jupyter_notebook(
|
66
|
+
file_path: str,
|
67
|
+
directive: str,
|
68
|
+
server: str,
|
69
|
+
url: str,
|
70
|
+
userid: str,
|
71
|
+
user_pass: str,
|
72
|
+
):
|
73
|
+
client = EgeriaTech(server, url, user_id=userid)
|
74
|
+
token = client.create_egeria_bearer_token(userid, user_pass)
|
75
|
+
#
|
76
|
+
# parsed_notebook = JupyterNotebookParser(file_path)
|
77
|
+
#
|
78
|
+
# cell_sources = parsed_notebook.get_markdown_cell_sources()
|
79
|
+
try:
|
80
|
+
updated = False
|
81
|
+
full_file_path = os.path.join(EGERIA_ROOT_PATH, EGERIA_FREDDIE_INBOX_PATH, file_path)
|
82
|
+
click.echo(f"Processing notebook: {full_file_path}")
|
83
|
+
with open(full_file_path, 'r') as f:
|
84
|
+
nb = nbformat.read(f, as_version=4)
|
85
|
+
for cell in nb.cells:
|
86
|
+
if cell.cell_type == 'markdown':
|
87
|
+
if cell.source.strip().startswith('#'):
|
88
|
+
potential_command = extract_command(cell.source)
|
89
|
+
if potential_command in commands:
|
90
|
+
if potential_command in ["Create Glossary", "Update Glossary"]:
|
91
|
+
result = process_glossary_upsert_command(client, cell.source, directive)
|
92
|
+
if result:
|
93
|
+
if directive == "process":
|
94
|
+
updated = True
|
95
|
+
cell.source = result
|
96
|
+
else:
|
97
|
+
continue
|
98
|
+
if potential_command in ["Create Term", "Update Term"]:
|
99
|
+
result = process_term_upsert_command(client, cell.source, directive)
|
100
|
+
if result:
|
101
|
+
if directive == "process":
|
102
|
+
updated = True
|
103
|
+
cell.source = result
|
104
|
+
else:
|
105
|
+
continue
|
106
|
+
|
107
|
+
if updated:
|
108
|
+
path, filename = os.path.split(file_path) # Get both parts
|
109
|
+
new_filename = f"processed-{get_current_datetime_string()}-{filename}" # Create the new filename
|
110
|
+
new_file_path = os.path.join(EGERIA_ROOT_PATH, EGERIA_FREDDIE_OUTBOX_PATH, new_filename) # Construct the new path
|
111
|
+
os.makedirs(os.path.dirname(new_file_path), exist_ok=True)
|
112
|
+
|
113
|
+
|
114
|
+
with open(new_file_path, 'w') as f2:
|
115
|
+
nbformat.write(nb, f2)
|
116
|
+
click.echo(f"\n==>Notebook written to {new_file_path}")
|
117
|
+
|
118
|
+
except Exception as e:
|
119
|
+
print_exception_response(e)
|
120
|
+
return
|
121
|
+
|
122
|
+
|
123
|
+
if __name__ == "__main__":
|
124
|
+
process_jupyter_notebook()
|
@@ -0,0 +1,158 @@
|
|
1
|
+
"""
|
2
|
+
This is an ongoing experiment in parsing and playing with Freddie docs
|
3
|
+
"""
|
4
|
+
import json
|
5
|
+
import mistune
|
6
|
+
from jupyter_notebook_parser import JupyterNotebookParser
|
7
|
+
import nbformat
|
8
|
+
import os
|
9
|
+
import re
|
10
|
+
from pyegeria import EgeriaTech
|
11
|
+
from rich import box, print
|
12
|
+
from rich.console import Console
|
13
|
+
from rich.markdown import Markdown
|
14
|
+
from rich.prompt import Prompt
|
15
|
+
from rich.table import Table
|
16
|
+
from freddie_utils import (extract_command, process_glossary_upsert_command, process_term_upsert_command,
|
17
|
+
get_current_datetime_string, process_per_proj_upsert_command, commands)
|
18
|
+
|
19
|
+
import click
|
20
|
+
from pyegeria import EgeriaTech, body_slimmer, NO_GLOSSARIES_FOUND, NO_TERMS_FOUND, NO_ELEMENTS_FOUND
|
21
|
+
from pyegeria._exceptions import (
|
22
|
+
InvalidParameterException,
|
23
|
+
PropertyServerException,
|
24
|
+
print_exception_response,
|
25
|
+
)
|
26
|
+
import datetime
|
27
|
+
|
28
|
+
EGERIA_METADATA_STORE = os.environ.get("EGERIA_METADATA_STORE", "active-metadata-store")
|
29
|
+
EGERIA_KAFKA_ENDPOINT = os.environ.get("KAFKA_ENDPOINT", "localhost:9092")
|
30
|
+
EGERIA_PLATFORM_URL = os.environ.get("EGERIA_PLATFORM_URL", "https://localhost:9443")
|
31
|
+
EGERIA_VIEW_SERVER = os.environ.get("EGERIA_VIEW_SERVER", "view-server")
|
32
|
+
EGERIA_VIEW_SERVER_URL = os.environ.get(
|
33
|
+
"EGERIA_VIEW_SERVER_URL", "https://localhost:9443"
|
34
|
+
)
|
35
|
+
EGERIA_INTEGRATION_DAEMON = os.environ.get("EGERIA_INTEGRATION_DAEMON", "integration-daemon")
|
36
|
+
EGERIA_INTEGRATION_DAEMON_URL = os.environ.get(
|
37
|
+
"EGERIA_INTEGRATION_DAEMON_URL", "https://localhost:9443"
|
38
|
+
)
|
39
|
+
EGERIA_ADMIN_USER = os.environ.get("ADMIN_USER", "garygeeke")
|
40
|
+
EGERIA_ADMIN_PASSWORD = os.environ.get("ADMIN_PASSWORD", "secret")
|
41
|
+
EGERIA_USER = os.environ.get("EGERIA_USER", "erinoverview")
|
42
|
+
EGERIA_USER_PASSWORD = os.environ.get("EGERIA_USER_PASSWORD", "secret")
|
43
|
+
EGERIA_WIDTH = os.environ.get("EGERIA_WIDTH", 220)
|
44
|
+
EGERIA_JUPYTER = os.environ.get("EGERIA_JUPYTER", False)
|
45
|
+
EGERIA_HOME_GLOSSARY_GUID = os.environ.get("EGERIA_HOME_GLOSSARY_GUID", None)
|
46
|
+
EGERIA_GLOSSARY_PATH = os.environ.get("EGERIA_GLOSSARY_PATH", None)
|
47
|
+
EGERIA_ROOT_PATH = os.environ.get("EGERIA_ROOT_PATH", "/Users/dwolfson/localGit/egeria-v5-3/egeria-workspaces")
|
48
|
+
EGERIA_FREDDIE_INBOX_PATH = os.environ.get("EGERIA_FREDDIE_INBOX_PATH", "exchange/loading-bay/freddies-inbox")
|
49
|
+
EGERIA_FREDDIE_OUTBOX_PATH = os.environ.get("EGERIA_FREDDIE_OUTBOX_PATH", "exchange/distribution-hub/freddies-outbox")
|
50
|
+
console = Console(width=int(EGERIA_WIDTH))
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
@click.command("process-markdown-file", help="Process a markdown file and return the output as a string.")
|
55
|
+
@click.option("--file-path", help="File path to markdown file",
|
56
|
+
default="glossary_exp.md")
|
57
|
+
@click.option("--directive", default="display", help="How to process the file")
|
58
|
+
@click.option("--server", default=EGERIA_VIEW_SERVER, help="Egeria view server to use.")
|
59
|
+
@click.option(
|
60
|
+
"--url", default=EGERIA_VIEW_SERVER_URL, help="URL of Egeria platform to connect to"
|
61
|
+
)
|
62
|
+
@click.option("--userid", default=EGERIA_USER, help="Egeria user")
|
63
|
+
@click.option("--user_pass", default=EGERIA_USER_PASSWORD, help="Egeria user password")
|
64
|
+
def process_markdown_file(
|
65
|
+
file_path: str,
|
66
|
+
directive: str,
|
67
|
+
server: str,
|
68
|
+
url: str,
|
69
|
+
userid: str,
|
70
|
+
user_pass: str,
|
71
|
+
):
|
72
|
+
client = EgeriaTech(server, url, user_id=userid)
|
73
|
+
token = client.create_egeria_bearer_token(userid, user_pass)
|
74
|
+
|
75
|
+
updated = False
|
76
|
+
full_file_path = os.path.join(EGERIA_ROOT_PATH, EGERIA_FREDDIE_INBOX_PATH, file_path)
|
77
|
+
print(f"Processing Markdown File: {full_file_path}")
|
78
|
+
try:
|
79
|
+
with open(full_file_path, 'r') as f:
|
80
|
+
lines = f.readlines()
|
81
|
+
except FileNotFoundError:
|
82
|
+
print(f"Error: File not found at path: {full_file_path}")
|
83
|
+
return {} # Return empty dict if file not found
|
84
|
+
|
85
|
+
h1_blocks = []
|
86
|
+
current_block = ""
|
87
|
+
in_h1_block = False
|
88
|
+
|
89
|
+
for line in lines:
|
90
|
+
line = line.strip() # Remove leading/trailing whitespace
|
91
|
+
|
92
|
+
if line.startswith("# ") and not in_h1_block: # Start of a new H1 block
|
93
|
+
if current_block:
|
94
|
+
h1_blocks.append(current_block)
|
95
|
+
current_block = line
|
96
|
+
in_h1_block = True
|
97
|
+
elif line == "---" and in_h1_block: # End of the current H1 block
|
98
|
+
h1_blocks.append(current_block)
|
99
|
+
current_block = ""
|
100
|
+
in_h1_block = False
|
101
|
+
elif in_h1_block: # Add line to the current H1 block
|
102
|
+
current_block += "\n" + line
|
103
|
+
|
104
|
+
if current_block: # Add the last H1 block
|
105
|
+
h1_blocks.append(current_block)
|
106
|
+
|
107
|
+
processed_blocks = ''
|
108
|
+
for block in h1_blocks:
|
109
|
+
potential_command = extract_command(block)
|
110
|
+
|
111
|
+
if potential_command in commands:
|
112
|
+
if potential_command in ["Create Glossary", "Update Glossary"]:
|
113
|
+
result = process_glossary_upsert_command(client, block, directive)
|
114
|
+
if result:
|
115
|
+
if directive == "process":
|
116
|
+
updated = True
|
117
|
+
processed_blocks += f'\n---\n{result} \n---\n'
|
118
|
+
else:
|
119
|
+
print(f"\n==>\tErrors found while processing command: \'{potential_command}\'\n"
|
120
|
+
f"\tPlease correct and try again. \n")
|
121
|
+
continue
|
122
|
+
if potential_command in ["Create Term", "Update Term"]:
|
123
|
+
result = process_term_upsert_command(client, block, directive)
|
124
|
+
if result:
|
125
|
+
if directive == "process":
|
126
|
+
updated = True
|
127
|
+
processed_blocks += f'\n---\n{result} \n---\n\n'
|
128
|
+
else:
|
129
|
+
print(f"\n==>\tErrors found while processing command: \'{potential_command}\'\n"
|
130
|
+
f"\tPlease correct and try again. \n")
|
131
|
+
continue
|
132
|
+
|
133
|
+
if potential_command in ["Create Personal Project", "Update Personal Project"]:
|
134
|
+
result = process_per_proj_upsert_command(client, block, directive)
|
135
|
+
if result:
|
136
|
+
if directive == "process":
|
137
|
+
updated = True
|
138
|
+
processed_blocks += f'\n---\n{result} \n---\n\n'
|
139
|
+
else:
|
140
|
+
print(f"\n==>\tErrors found while processing command: \'{potential_command}\'\n"
|
141
|
+
f"\tPlease correct and try again. \n")
|
142
|
+
continue
|
143
|
+
|
144
|
+
if updated:
|
145
|
+
path, filename = os.path.split(file_path) # Get both parts
|
146
|
+
new_filename = f"processed-{get_current_datetime_string()}-{filename}" # Create the new filename
|
147
|
+
new_file_path = os.path.join(EGERIA_ROOT_PATH, EGERIA_FREDDIE_OUTBOX_PATH, new_filename) # Construct the new path
|
148
|
+
os.makedirs(os.path.dirname(new_file_path), exist_ok=True)
|
149
|
+
|
150
|
+
|
151
|
+
with open(new_file_path, 'w') as f2:
|
152
|
+
f2.write(processed_blocks)
|
153
|
+
click.echo(f"\n==>Notebook written to {new_file_path}")
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
if __name__ == "__main__":
|
158
|
+
process_markdown_file()
|