未验证 提交 41f17aeb 编写于 作者: S Steffy-zxf 提交者: GitHub

fix DATA_HOME path in win (#29222)

* fix DATA_HOME path in win
上级 3765da98
......@@ -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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册