MCPcopy Index your code
hub / github.com/davispuh/MySQL-for-Python-3 / _patch_file

Function _patch_file

distribute_setup.py:233–247  ·  view source on GitHub ↗

Will backup the file then patch it

(path, content)

Source from the content-addressed store, hash-verified

231
232
233def _patch_file(path, content):
234 """Will backup the file then patch it"""
235 existing_content = open(path).read()
236 if existing_content == content:
237 # already patched
238 log.warn('Already patched.')
239 return False
240 log.warn('Patching...')
241 _rename_path(path)
242 f = open(path, 'w')
243 try:
244 f.write(content)
245 finally:
246 f.close()
247 return True
248
249_patch_file = _no_sandbox(_patch_file)
250

Callers 1

Calls 2

_rename_pathFunction · 0.85
closeMethod · 0.80

Tested by

no test coverage detected