MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / file_cmp

Function file_cmp

src/commoncode/testcase.py:268–281  ·  view source on GitHub ↗

Compare two files content. Return False if they differ, True is they are the same.

(file1, file2, ignore_line_endings=False)

Source from the content-addressed store, hash-verified

266
267
268def file_cmp(file1, file2, ignore_line_endings=False):
269 """
270 Compare two files content.
271 Return False if they differ, True is they are the same.
272 """
273 with open(file1, "rb") as f1:
274 f1c = f1.read()
275 if ignore_line_endings:
276 f1c = b"\n".join(f1c.splitlines(False))
277 with open(file2, "rb") as f2:
278 f2c = f2.read()
279 if ignore_line_endings:
280 f2c = b"\n".join(f2c.splitlines(False))
281 assert f2c == f1c
282
283
284def make_non_readable(location):

Callers

nothing calls this directly

Calls 2

readMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected