golden hour
/usr/local/lib/python3.6/site-packages/filelock
⬆️ Go Up
Upload
File/Folder
Size
Actions
__init__.py
1.21 KB
Del
OK
__pycache__
-
Del
OK
_api.py
8.19 KB
Del
OK
_error.py
362 B
Del
OK
_soft.py
1.58 KB
Del
OK
_unix.py
1.38 KB
Del
OK
_util.py
558 B
Del
OK
_windows.py
1.69 KB
Del
OK
py.typed
0 B
Del
OK
version.py
142 B
Del
OK
Edit: _util.py
import os import stat def raise_on_exist_ro_file(filename: str) -> None: try: file_stat = os.stat(filename) # use stat to do exists + can write to check without race condition except OSError: return None # swallow does not exist or other errors if file_stat.st_mtime != 0: # if os.stat returns but modification is zero that's an invalid os.stat - ignore it if not (file_stat.st_mode & stat.S_IWUSR): raise PermissionError(f"Permission denied: {filename!r}") __all__ = [ "raise_on_exist_ro_file", ]
Save