Use os.remove instead of shutil.rmtree if we try to remove a symbolic link

If we try to remove a symbolic link to a directory with shutil.rmtree, we get
the error “Cannot call rmtree on a symbolic link”
This commit is contained in:
Jason Grout 2014-11-19 04:46:13 -05:00
parent 2414db41e6
commit 5a39c0c9bd

View File

@ -149,7 +149,7 @@ def install_nbextension(files, overwrite=False, symlink=False, ipython_dir=None,
if overwrite and os.path.exists(dest):
if verbose >= 1:
print("removing %s" % dest)
if os.path.isdir(dest):
if os.path.isdir(dest) and not os.path.islink(dest):
shutil.rmtree(dest)
else:
os.remove(dest)