Unverified 提交 b551098d authored 作者: Code-Bat's avatar Code-Bat 提交者: GitHub

About "os.R_OK" in general.py (#8909)

The notes says "Return True if directory has write permissions", however, the code below is "os.R_OK", I think "os.W_OK" is preferred.
上级 f5335f22
...@@ -69,7 +69,7 @@ def is_kaggle(): ...@@ -69,7 +69,7 @@ def is_kaggle():
def is_writeable(dir, test=False): def is_writeable(dir, test=False):
# Return True if directory has write permissions, test opening a file with write permissions if test=True # Return True if directory has write permissions, test opening a file with write permissions if test=True
if not test: if not test:
return os.access(dir, os.R_OK) # possible issues on Windows return os.access(dir, os.W_OK) # possible issues on Windows
file = Path(dir) / 'tmp.txt' file = Path(dir) / 'tmp.txt'
try: try:
with open(file, 'w'): # open file with write permissions with open(file, 'w'): # open file with write permissions
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论