(fpath: str)
Like windows_proof_rmtree, but for a single file.
Like windows_proof_rmtree, but for a single file.
Like windows_proof_rmtree but for a single file .
def windows_proof_rm(fpath: str) -> None:
    """Like windows_proof_rmtree, but for a single file."""
    if os.path.isfile(fpath):
        os.chmod(fpath, os.stat(fpath).st_mode | stat.S_IWRITE | stat.S_IREAD)
    delays = [0.1, 0.1, 0.2, 0.2, 0.2, 0.5, 0.5, 1, 1, 1, 1, 2]
    for d in delays:
        try:
            os.unlink(fpath)
            return
        except FileNotFoundError:
            return
        except OSError:
            time.sleep(d)
    os.unlink(fpath)
def windows_proof_rm ( fpath : str ) -> None : if os . path . isfile ( fpath ) : os . chmod ( fpath , os . stat ( fpath ) . st_mode | stat . S_IWRITE | stat . S_IREAD ) delays = [ 0.1 , 0.1 , 0.2 , 0.2 , 0.2 , 0.5 , 0.5 , 1 , 1 , 1 , 1 , 2 ] for d in delays : try : os . unlink ( fpath ) return except FileNotFoundError : return except OSError : time . sleep ( d ) os . unlink ( fpath )