-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfilecmp_cmp.py
More file actions
42 lines (38 loc) · 1.02 KB
/
filecmp_cmp.py
File metadata and controls
42 lines (38 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# cmp() compares two files on the file system
# shallow -- Just check stat signature (do not read the files). defaults to True.
# When shallow is False, the contents of the file are always compared
import filecmp
print("common_file: ", end=" ")
print(
filecmp.cmp("example/dir1/common_file", "example/dir2/common_file", shallow=True),
end=" ",
)
print(
filecmp.cmp("example/dir1/common_file", "example/dir2/common_file", shallow=False),
)
print("contents_differ: ", end=" ")
print(
filecmp.cmp(
"example/dir1/contents_differ", "example/dir2/contents_differ", shallow=True
),
end=" ",
)
print(
filecmp.cmp(
"example/dir1/contents_differ", "example/dir2/contents_differ", shallow=False
),
)
print("identical: ", end=" ")
print(
filecmp.cmp(
"example/dir1/file_only_in_dir1", "example/dir1/file_only_in_dir1", shallow=True
),
end=" ",
)
print(
filecmp.cmp(
"example/dir1/file_only_in_dir1",
"example/dir1/file_only_in_dir1",
shallow=False,
),
)