From 49f398ea40b4625c171ed4753dc930ed82dc1a72 Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Mon, 11 Sep 2023 17:15:40 -0700 Subject: [PATCH] use relative paths in build --- build.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/build.py b/build.py index c160a5c..b6e4c4e 100755 --- a/build.py +++ b/build.py @@ -16,8 +16,8 @@ def main(): parser.add_argument("out", help="output directory", nargs="?", default="./out") args = parser.parse_args() - src = pathlib.Path(args.src).absolute() - out = pathlib.Path(args.out).absolute() + src = pathlib.Path(args.src) + out = pathlib.Path(args.out) md = markdown.Markdown(extensions=["attr_list", "footnotes", "meta"]) @@ -31,10 +31,9 @@ def main(): (src / ".template.html").read_text(encoding="utf8"), features="html.parser") - # cd to src so os.walk(.) returns paths relative to src - os.chdir(src) count = 0 - for dirpath, dirnames, filenames in os.walk("."): + for dirpath, _, filenames in os.walk(src): + dirpath = pathlib.Path(dirpath).relative_to(src) for filename in filenames: if filename[0] == ".": continue # Skip dotfiles