Skip to content
Snippets Groups Projects
Commit 7c62b7fb authored by Axel Farrugia's avatar Axel Farrugia
Browse files

[Fix] copy_folder() function now create the parent directory before creating the symlink

parent 0547c662
No related branches found
No related tags found
3 merge requests!414Update version 0.5.1 -> 0.6.0,!408[Add] Dropout Operator,!369[Feat](Exports) Minor features for export generation
......@@ -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:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment