From 323ce158f9c42c2cf262c3b2d863b40823dfdf15 Mon Sep 17 00:00:00 2001 From: xenofem Date: Tue, 23 Jan 2024 17:35:01 -0500 Subject: [PATCH] fancier recursive copy function we didn't end up needing --- dlibrary/dlibrary.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/dlibrary/dlibrary.py b/dlibrary/dlibrary.py index e6e910a..986a824 100755 --- a/dlibrary/dlibrary.py +++ b/dlibrary/dlibrary.py @@ -298,10 +298,13 @@ 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(): - 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): jenv = Environment( @@ -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))