Will backup the file then patch it
(path, content)
| 231 | |
| 232 | |
| 233 | def _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 |
no test coverage detected