Pack project: Raise exception with reasonable message (#5145)

* raise exception with reasonable message

* raise errors at better places
This commit is contained in:
Jakub Trllo 2023-06-15 14:32:53 +02:00 committed by GitHub
parent 59b7e265da
commit 22296aeb6e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

View file

@ -113,6 +113,12 @@ def pack_project(
project_name
))
if only_documents and not destination_dir:
raise ValueError((
"Destination directory must be defined"
" when only documents should be packed."
))
root_path = None
source_root = {}
project_source_path = None
@ -141,6 +147,11 @@ def pack_project(
if not destination_dir:
destination_dir = root_path
if not destination_dir:
raise ValueError(
"Project {} does not have any roots.".format(project_name)
)
destination_dir = os.path.normpath(destination_dir)
if not os.path.exists(destination_dir):
os.makedirs(destination_dir)