MCPcopy Create free account
hub / github.com/ActiveState/code / replace

Function replace

recipes/Python/579097_Safely_atomically_write/recipe-579097.py:67–75  ·  view source on GitHub ↗
(source, destination)

Source from the content-addressed store, hash-verified

65 # But it's how (for example) Mercurial does it, as of 2016-03-23
66 # https://selenic.com/repo/hg/file/tip/mercurial/windows.py
67 def replace(source, destination):
68 assert sys.platform == 'win32'
69 try:
70 os.rename(source, dest)
71 except OSError as err:
72 if err.winerr != 183:
73 raise
74 os.remove(dest)
75 os.rename(source, dest)
76 else:
77 # Atomic on POSIX. Not sure about Cygwin, OS/2 or others.
78 replace = os.rename

Callers 7

isRunningFunction · 0.85
killAllFunction · 0.85
atomic_writeFunction · 0.85
_escape_cdataFunction · 0.85
_escape_attribFunction · 0.85
OnDoubleClickMethod · 0.85

Calls 2

renameMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected