-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
36 lines (27 loc) · 1.25 KB
/
Copy pathrun.py
File metadata and controls
36 lines (27 loc) · 1.25 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
"""
02 -- build-pipeline
The full pipeline in one call: a shared brand <layout> (which itself
pulls in the shared header and footer <include>s), a linked SCSS theme,
and CSS inlining -- everything inky.transform() alone doesn't do.
"""
import os
import sys
sys.path.insert(0, os.path.normpath(os.path.join(os.path.dirname(__file__), "..", "..")))
import bootstrap # noqa: E402
import inky # noqa: E402
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
dist = bootstrap.inky_example("02-build-pipeline")
with open(os.path.join(THIS_DIR, "email.inky"), encoding="utf-8") as f:
source = f.read()
# base_path anchors every relative <layout>/<include>/<link> path in the
# template AND in anything it includes (see SUITE.md "Runtime
# requirements" -- the layout's own includes resolve against THIS path,
# not against shared/'s location). Passing THIS_DIR (examples/02-build-pipeline/)
# is why every shared/ reference in email.inky and shared/layout.html
# uses "../../shared/...".
result = inky.build(source, THIS_DIR)
with open(os.path.join(dist, "email.html"), "w", encoding="utf-8") as f:
f.write(result.html)
for warning in result.warnings:
print(f"warning: {warning}", file=sys.stderr)
print(f"email.html: {len(result.html.encode('utf-8'))} bytes")