diff --git a/aidge_core/export_utils/code_generation.py b/aidge_core/export_utils/code_generation.py index 42ae19f7937a3a45ace65ad708a44aac5a199405..8b3bf65ed9b888db4212f623aae216965109a543 100644 --- a/aidge_core/export_utils/code_generation.py +++ b/aidge_core/export_utils/code_generation.py @@ -44,7 +44,7 @@ def generate_str(template_path: Union[Path, str], **kwargs) -> str: return Environment(loader=FileSystemLoader( template_path.parent), undefined=StrictUndefined, keep_trailing_newline=True).get_template(template_path.name).render(kwargs) -def copy_file(filename, dst_folder, symlink=False): +def copy_file(filename: Union[Path, str], dst_folder: Union[Path, str], symlink=False): """Copy the given file into the given dst path The symlink arg allows to make a symbolic link instead of copying the file. """ @@ -60,11 +60,16 @@ def copy_file(filename, dst_folder, symlink=False): else: shutil.copy(filename, dst_folder) -def copy_folder(foldername, dst_folder, symlink=False): +def copy_folder(foldername: Union[Path, str], dst_folder: Union[Path, str], symlink=False): """Copy the given folder into the given dst path The symlink arg allows to make a symbolic link instead of copying the file. """ + # If the parent directory doesn't exist, create it + parent_dir = Path(dst_folder).parent + if not os.path.exists(parent_dir): + os.makedirs(parent_dir) + if symlink: os.symlink(foldername, dst_folder) else: