MCPcopy Create free account
hub / github.com/fabioz/PyDev.Debugger / make_replace

Function make_replace

build_tools/rename_pep8.py:52–72  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

50
51
52def 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
75def load_re_to_new_val(names):

Callers 1

rename_pep8.pyFile · 0.85

Calls 5

load_re_to_new_valFunction · 0.85
iter_files_in_dirFunction · 0.85
substitute_contentsFunction · 0.85
itervaluesMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected