Destination directories now get created when needed

This commit is contained in:
Jef Roosens 2021-01-16 09:36:23 +01:00
parent 310ac3784e
commit 2660af23d8
3 changed files with 8 additions and 19 deletions

View file

@ -45,10 +45,13 @@ class Spec:
destination if type(destination) == Path else Path(destination)
)
# Check existence of destination folder
if not self.destination.exists() or not self.destination.is_dir():
# Create destination if non-existent
try:
self.destination.mkdir(parents=True, exist_ok=True)
except FileExistsError:
raise NotADirectoryError(
"{} doesn't exist or isn't a directory.".format(
"{} already exists, but isn't a directory.".format(
self.destination
)
)