Index

joshstock.in / 0fe4f18

Source for serving and static templating/compiling of https://joshstock.in.

Latest Commit

{#}TimeHashSubjectAuthor#(+)(-)GPG?
15814 Jan 2023 23:375aaa26aWebsite rewriteJosh Stockin1290G

Blob @ joshstock.in / build.py

application/x-python772 bytesdownload raw
1#!/usr/bin/env python3
2
3import shutil
4import os
5import sys
6
7# Path of build script
8current_dir = os.path.realpath(os.path.dirname(__file__))
9
10# Path of build output, clear and recreate
11buildpath = os.path.join(current_dir, "build")
12shutil.rmtree(buildpath, ignore_errors=True)
13os.makedirs(buildpath, exist_ok=False)
14
15# Add template generator directory as top level path (lets us directly import targets.py)
16sitepath = os.path.join(current_dir, "site")
17sys.path.insert(0, sitepath)
18import targets
19
20files = targets.template()
21
22for file in files.keys():
23 content = files[file]
24 path = os.path.join(buildpath, file)
25 print(f"Writing file {path}")
26 os.makedirs(os.path.dirname(path), exist_ok=True)
27 buf = open(path, "wb")
28 buf.write(content)
29 buf.close()
30