refactor(KIAUH): use pathlib instead of os where possible. consistent use of pathlib.

Signed-off-by: Dominik Willner <th33xitus@gmail.com>
This commit is contained in:
dw-0
2023-12-25 00:59:00 +01:00
parent da533fdd67
commit 8aeb01aca0
23 changed files with 207 additions and 209 deletions

View File

@@ -47,7 +47,7 @@ class BackupManager:
filename = custom_filename if custom_filename is not None else filename
try:
Path(target).mkdir(exist_ok=True)
shutil.copyfile(file, Path(target, filename))
shutil.copyfile(file, target.joinpath(filename))
except OSError as e:
Logger.print_error(f"Unable to backup '{file}':\n{e}")
continue
@@ -64,7 +64,7 @@ class BackupManager:
Logger.print_status(log)
date = get_current_date().get("date")
time = get_current_date().get("time")
shutil.copytree(source, Path(target, f"{name}-{date}-{time}"))
shutil.copytree(source, target.joinpath(f"{name}-{date}-{time}"))
except OSError as e:
Logger.print_error(f"Unable to backup directory '{source}':\n{e}")
return