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

Function confirm_merge

example_code/item_078.py:235–250  ·  view source on GitHub ↗
(input_paths, output_path)

Source from the content-addressed store, hash-verified

233
234print("Example 10")
235def confirm_merge(input_paths, output_path):
236 found = collections.defaultdict(list)
237 with open(output_path, "rb") as f:
238 for line in f:
239 for path in input_paths:
240 if line.find(path.encode()) == 0:
241 found[path].append(line)
242
243 expected = collections.defaultdict(list)
244 for path in input_paths:
245 with open(path, "rb") as f:
246 expected[path].extend(f.readlines())
247
248 for key, expected_lines in expected.items():
249 found_lines = found[key]
250 assert expected_lines == found_lines
251
252input_paths = ...
253handles = ...

Callers 1

item_078.pyFile · 0.70

Calls 2

openFunction · 0.85
appendMethod · 0.45

Tested by

no test coverage detected