-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfull.py
More file actions
62 lines (43 loc) · 1.33 KB
/
full.py
File metadata and controls
62 lines (43 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Convert a corpus of Bywd modules into HTML.
"""
import pathlib
import sys
import typing
from icecream import ic
import requests_cache
import bwyd
if __name__ == "__main__":
dsl: bwyd.Bwyd = bwyd.Bwyd(
config_path = pathlib.Path("config.toml"),
)
dsl.extend_converter([
#bwyd.Conversion.model_validate({ "symbol": "vodka", "density": 222.4, })
])
## render each module as HTML
corpus: bwyd.Corpus = dsl.build_corpus()
dir_path: pathlib.Path = pathlib.Path("examples")
module_iter: typing.Iterator[ bwyd.Module ] = corpus.parse_modules(
dir_path,
#glob = "potato*.bwyd",
debug = True, # False
)
modules: list[ bwyd.Module ] = []
for module in module_iter:
modules.append(module)
# render HTML using the Jinja2 template
html_path: pathlib.Path = module.path.with_suffix(".html")
with open(html_path, "w", encoding = "utf-8") as fp:
fp.write(module.render_template())
## search/discovery support
corpus.render_discovery(
modules,
dir_path / "index.html",
)
## KG prototype support
sys.exit(0)
graph: bwyd.Graph = corpus.build_graph(modules)
with open("kg.rdf", "w", encoding = "utf-8") as fp:
fp.write(graph.serialize())