-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdodo.py
110 lines (96 loc) · 2.74 KB
/
dodo.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
from s4ge import utils, app, config
md_source = utils.get_all_files(config.SOURCE_PATH, utils.is_markdown)
md_source_root = config.SOURCE_PATH
other_source = utils.get_all_files(
config.SOURCE_PATH, lambda s: not utils.is_markdown(s)
)
md_cleaned_root = config.INTERMEDIARY_PATH / "md_cleaned"
md_cleaned = utils.replicate(
md_source, target=md_cleaned_root, relative_to=config.SOURCE_PATH
)
full_config_file = md_cleaned_root / "_values.json"
md_templated_root = config.INTERMEDIARY_PATH / "md_templated"
md_templated = utils.replicate(
md_cleaned, target=md_templated_root, relative_to=md_cleaned_root
)
md_to_html_root = config.INTERMEDIARY_PATH / "md_to_html"
md_to_html = list(
map(
lambda s: s.with_suffix(".html"),
utils.replicate(
md_source, target=md_to_html_root, relative_to=config.SOURCE_PATH
),
)
)
def task_clean_source():
return {
"file_dep": md_source,
"targets": md_cleaned,
"actions": [
(
app.clean_source,
(),
{
"dep_root": md_source_root,
"full_config": full_config_file,
},
)
],
"clean": [f"rm -r {md_cleaned_root}/*"],
}
def task_render_md_templates():
return {
"file_dep": md_cleaned,
"targets": md_templated,
"actions": [
(
app.render_md_templated,
(),
{
"dep_root": md_cleaned_root,
"full_config": full_config_file,
},
)
],
"clean": True,
}
def task_render_md_to_html():
return {
"file_dep": md_templated,
"targets": md_to_html,
"actions": [app.render_md_to_html],
"clean": True,
}
def task_render_to_template():
return {
"file_dep": md_to_html,
"targets": utils.replicate(
md_to_html,
relative_to=md_to_html_root,
target=config.DESTINATION_PATH,
),
"actions": [
(
app.render_to_template,
(),
{
"dep_root": md_to_html_root,
"full_config": full_config_file,
},
)
],
"clean": True,
}
def task_copy_resources(): # Task 'cp resources'
return {
"file_dep": other_source,
"targets": utils.replicate(
other_source,
relative_to=config.SOURCE_PATH,
target=config.DESTINATION_PATH,
),
"actions": [
f'rsync -a --checksum --exclude="*.md" {config.SOURCE_PATH}/* {config.DESTINATION_PATH}/'
],
"clean": True,
}