-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmuff.py
65 lines (49 loc) · 1.59 KB
/
muff.py
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
63
64
65
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Convert a corpus of Bywd modules into HTML.
"""
import pathlib
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"),
)
corpus: bwyd.Corpus = dsl.build_corpus()
session: requests_cache.CachedSession = corpus.get_cache()
examples_path: pathlib.Path = pathlib.Path("examples")
modules: typing.List[ bwyd.Module ] = corpus.render_html_files(
examples_path,
#glob = "bread*.bwyd",
#glob = "app*.bwyd",
debug = True, # False
)
mod_data: dict = {
"corpus": {
"icon": bwyd.BWYD_SVG,
"modules": [
{
"slug": module.slug,
"thumb": module.get_thumbnail(session),
"title": module.title,
"text": module.text,
"serves": module.total_yields(),
"duration": module.total_duration(),
"updated": module.updated,
"keywords": module.collect_keywords(),
}
for module in modules
],
},
}
#ic(mod_data)
html: str = bwyd.JINJA_INDEX_TEMPLATE.render(mod_data)
with open(examples_path / "index.html", "w", encoding = "utf-8") as fp:
fp.write(html)
## KG prototype support
graph: bwyd.Graph = corpus.build_graph(modules)
with open("kg.rdf", "w", encoding = "utf-8") as fp:
fp.write(graph.serialize())