MCPcopy Create free account
hub / github.com/bslatkin/effectivepython / confirm_merge

Function confirm_merge

example_code/item_077.py:153–170  ·  view source on GitHub ↗
(input_paths, output_path)

Source from the content-addressed store, hash-verified

151
152print("Example 5")
153def confirm_merge(input_paths, output_path):
154 found = collections.defaultdict(list)
155 with open(output_path, "rb") as f:
156 for line in f:
157 for path in input_paths:
158 if line.find(path.encode()) == 0:
159 found[path].append(line)
160
161 expected = collections.defaultdict(list)
162 for path in input_paths:
163 with open(path, "rb") as f:
164 expected[path].extend(f.readlines())
165
166 for key, expected_lines in expected.items():
167 found_lines = found[key]
168 assert (
169 expected_lines == found_lines
170 ), f"{expected_lines!r} == {found_lines!r}"
171
172input_paths = ...
173handles = ...

Callers 1

item_077.pyFile · 0.70

Calls 2

openFunction · 0.85
appendMethod · 0.45

Tested by

no test coverage detected