Skip to content

Commit be29555

Browse files
committed
Use shutil to copy files, fixing Google Colab issue.
1 parent 1cabf78 commit be29555

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

camel_tools/data/downloader.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@
2323
# SOFTWARE.
2424

2525

26+
from genericpath import exists
2627
from pathlib import Path
2728
from tempfile import TemporaryDirectory
28-
from os import urandom, replace
29+
from os import urandom, remove
30+
from shutil import move, rmtree
2931
import binascii
3032
import zipfile
3133

@@ -83,6 +85,9 @@ def download(url,
8385
on_error=on_download_error)
8486

8587
if is_zip:
88+
if dst.exists():
89+
rmtree(dst)
90+
8691
# Extract data to destination directory
8792
HTTPDownloader._extract_content(tmp_data_path,
8893
dst,
@@ -91,7 +96,10 @@ def download(url,
9196
on_finish=on_unzip_finish,
9297
on_error=on_unzip_error)
9398
else:
94-
replace(tmp_data_path, dst)
99+
if dst.exists():
100+
remove(dst)
101+
102+
move(tmp_data_path, dst)
95103

96104
@staticmethod
97105
def _save_content(url,

0 commit comments

Comments
 (0)