()
| 50 | |
| 51 | |
| 52 | def make_replace(): |
| 53 | re_name_to_new_val = load_re_to_new_val(names_to_rename.NAMES) |
| 54 | # traverse root directory, and list directories as dirs and files as files |
| 55 | for path, initial_contents in iter_files_in_dir(os.path.dirname(os.path.dirname(__file__))): |
| 56 | contents = substitute_contents(re_name_to_new_val, initial_contents) |
| 57 | if contents != initial_contents: |
| 58 | print("Changed something at: %s" % (path,)) |
| 59 | |
| 60 | for val in re_name_to_new_val.itervalues(): |
| 61 | # Check in initial contents to see if it already existed! |
| 62 | if re.findall(r"\b%s\b" % (val,), initial_contents): |
| 63 | raise AssertionError( |
| 64 | "Error in:\n%s\n%s is already being used (and changes may conflict)." |
| 65 | % ( |
| 66 | path, |
| 67 | val, |
| 68 | ) |
| 69 | ) |
| 70 | |
| 71 | with open(path, "wb") as stream: |
| 72 | stream.write(contents) |
| 73 | |
| 74 | |
| 75 | def load_re_to_new_val(names): |
no test coverage detected