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,9 +298,12 @@ def metadata(args):
con.close()
def copy_contents(src, dest):
def copy_recursive(src, dest):
dest.mkdir(parents=True, exist_ok=True)
for item in src.iterdir():
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):
@ -402,7 +405,7 @@ def generate(args):
)
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:
f.write(list_template.render(depth=0, works=works))