fancier recursive copy function we didn't end up needing

This commit is contained in:
xenofem 2024-01-23 17:35:01 -05:00
parent 528ad4e6f2
commit 323ce158f9

View file

@ -298,10 +298,13 @@ def metadata(args):
con.close() con.close()
def copy_contents(src, dest): def copy_recursive(src, dest):
dest.mkdir(parents=True, exist_ok=True) dest.mkdir(parents=True, exist_ok=True)
for item in src.iterdir(): for item in src.iterdir():
shutil.copyfile(item, dest / item.name) if item.is_dir() and not item.is_symlink():
copy_recursive(item, dest / item.name)
else:
shutil.copyfile(item, dest / item.name)
def generate(args): def generate(args):
jenv = Environment( jenv = Environment(
@ -402,7 +405,7 @@ def generate(args):
) )
with resources.as_file(resources.files("dlibrary")) as r: with resources.as_file(resources.files("dlibrary")) as r:
copy_contents(r / 'static', args.destdir / 'site' / 'static') copy_recursive(r / 'static', args.destdir / 'site' / 'static')
with open(args.destdir / 'site' / 'index.html', 'w') as f: with open(args.destdir / 'site' / 'index.html', 'w') as f:
f.write(list_template.render(depth=0, works=works)) f.write(list_template.render(depth=0, works=works))