fix DATA_HOME path in win (#29222)

* fix DATA_HOME path in win
revert-31562-mean
Steffy-zxf 4 years ago committed by GitHub
parent 3765da98c7
commit 41f17aeb8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -34,7 +34,8 @@ __all__ = [
'cluster_files_reader',
]
DATA_HOME = os.path.expanduser('~/.cache/paddle/dataset')
HOME = os.path.expanduser('~')
DATA_HOME = os.path.join(HOME, '.cache', 'paddle', 'dataset')
# When running unit tests, there could be multiple processes that

@ -15,6 +15,7 @@
import unittest
from paddle.utils.download import get_weights_path_from_url
from paddle.utils.download import get_path_from_url
class TestDownload(unittest.TestCase):
@ -57,6 +58,18 @@ class TestDownload(unittest.TestCase):
for url in urls:
self.download(url, None)
def test_get_path_from_url(self):
urls = [
"https://paddle-hapi.bj.bcebos.com/unittest/files.tar",
"https://paddle-hapi.bj.bcebos.com/unittest/files.zip",
"https://paddle-hapi.bj.bcebos.com/unittest/single_dir.tar",
"https://paddle-hapi.bj.bcebos.com/unittest/single_dir.zip",
"https://paddle-hapi.bj.bcebos.com/unittest/single_file.tar",
"https://paddle-hapi.bj.bcebos.com/unittest/single_file.zip",
]
for url in urls:
get_path_from_url(url, root_dir='./test')
if __name__ == '__main__':
unittest.main()

@ -335,8 +335,16 @@ def _is_a_single_file(file_list):
def _is_a_single_dir(file_list):
file_name = file_list[0].split(os.sep)[0]
for i in range(1, len(file_list)):
if file_name != file_list[i].split(os.sep)[0]:
new_file_list = []
for file_path in file_list:
if '/' in file_path:
file_path = file_path.replace('/', os.sep)
elif '\\' in file_path:
file_path = file_path.replace('\\', os.sep)
new_file_list.append(file_path)
file_name = new_file_list[0].split(os.sep)[0]
for i in range(1, len(new_file_list)):
if file_name != new_file_list[i].split(os.sep)[0]:
return False
return True

Loading…
Cancel
Save