From 5d19e4641a4151058df8cc7d488cc60ff0849d99 Mon Sep 17 00:00:00 2001 From: Claire Xenia Wolf Date: Sun, 31 Oct 2021 14:43:02 +0100 Subject: [PATCH] Add support for directories in [files] section Signed-off-by: Claire Xenia Wolf --- sbysrc/sby_core.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sbysrc/sby_core.py b/sbysrc/sby_core.py index 979be6f..78220e5 100644 --- a/sbysrc/sby_core.py +++ b/sbysrc/sby_core.py @@ -20,7 +20,7 @@ import os, re, sys, signal if os.name == "posix": import resource, fcntl import subprocess -from shutil import copyfile, rmtree +from shutil import copyfile, copytree, rmtree from select import select from time import time, localtime, sleep @@ -332,7 +332,10 @@ class SbyJob: os.makedirs(basedir) self.log(f"Copy '{os.path.abspath(srcfile)}' to '{os.path.abspath(dstfile)}'.") - copyfile(srcfile, dstfile) + if os.path.isdir(srcfile): + copytree(srcfile, dstfile, dirs_exist_ok=True) + else: + copyfile(srcfile, dstfile) def handle_str_option(self, option_name, default_value): if option_name in self.options: -- 2.30.2