Skip to content

Commit c39cd65

Browse files
committed
Remove dependency on pathlib
1 parent d977d1b commit c39cd65

File tree

2 files changed

+22
-19
lines changed

2 files changed

+22
-19
lines changed

gdown/download_folder.py

+22-17
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
from __future__ import print_function
22

3-
from .download import download
4-
from bs4 import BeautifulSoup
5-
63
from builtins import bytes
74
from itertools import islice
85
import json
6+
import os
7+
import os.path as osp
98
import re
10-
import requests
119
import sys
1210

13-
if sys.version_info.major < 3:
14-
from pathlib2 import Path
15-
else:
16-
from pathlib import Path
11+
from bs4 import BeautifulSoup
12+
import requests
13+
14+
from .download import download
15+
16+
1717
client = requests.session()
1818

1919
folders_url = "https://drive.google.com/drive/folders/"
@@ -218,7 +218,7 @@ def get_directory_structure(gdrive_file, previous_path):
218218
----------
219219
gdrive_file: GoogleDriveFile
220220
Google Drive folder structure.
221-
previous_path: pathlib.Path
221+
previous_path: str
222222
Path containing the parent's file path.
223223
224224
Returns
@@ -229,11 +229,17 @@ def get_directory_structure(gdrive_file, previous_path):
229229
directory_structure = []
230230
for file in gdrive_file.children:
231231
if file.is_folder():
232-
directory_structure.append((None, previous_path / file.name))
233-
for i in get_directory_structure(file, previous_path / file.name):
232+
directory_structure.append(
233+
(None, osp.join(previous_path, file.name))
234+
)
235+
for i in get_directory_structure(
236+
file, osp.join(previous_path, file.name)
237+
):
234238
directory_structure.append(i)
235239
elif not file.children:
236-
directory_structure.append((file.id, previous_path / file.name))
240+
directory_structure.append(
241+
(file.id, osp.join(previous_path, file.name))
242+
)
237243
return directory_structure
238244

239245

@@ -302,12 +308,11 @@ def download_folder(
302308
print("Retrieving folder list completed", file=sys.stderr)
303309
print("Building directory structure", file=sys.stderr)
304310
if output is None:
305-
output = Path.cwd()
306-
else:
307-
output = Path(output)
308-
root_folder = output / gdrive_file.name
311+
output = os.getcwd()
312+
root_folder = osp.join(output, gdrive_file.name)
309313
directory_structure = get_directory_structure(gdrive_file, root_folder)
310-
root_folder.mkdir(parents=True, exist_ok=True)
314+
if not osp.exists(root_folder):
315+
os.makedirs(root_folder)
311316

312317
if not quiet:
313318
print("Building directory structure completed")

setup.py

-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ def get_long_description():
5555
"six",
5656
"tqdm",
5757
"beautifulsoup4",
58-
"pathlib2",
59-
"future",
6058
],
6159
description="Google Drive direct download of big files.",
6260
long_description=get_long_description(),

0 commit comments

Comments
 (0)