import os
import shutil
import stat
def _onerror(func, path, exc_info):
if not os.access(path, os.W_OK):
os.chmod(path, stat.S_IWUSR)
func(path)
else:
raise
def rm_rf(path: str):
if not os.path.exists(path):
return
shutil.rmtree(path, onerror=_onerror)