-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathCompare_Metadata.py
More file actions
71 lines (54 loc) · 2.43 KB
/
Copy pathCompare_Metadata.py
File metadata and controls
71 lines (54 loc) · 2.43 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import os
import codecs
import time
def loading():
# List of loading animation frames
frames = ["|", "/", "-", "\\"]
for frame in frames:
print(f"Loading... {frame}", end="\r")
# Wait for 500ms
time.sleep(0.2)
print("Loading complete!")
if __name__ == "__main__":
loading()
print("""
.=-.-. _,.---._ .-._ .=-.-. ,---.
/==/_ / .-.,.---. ,-.' , - `. /==/ \ .-._ /==/_ / .--.' \
|==|, | /==/ ` \ /==/_, , - \ |==|, \/ /, / |==|, | \==\-/\ \
|==| | |==|-, .=., | |==| .=. | |==|- \| | |==| | /==/-|_\ |
|==|- | |==| '=' / |==|_ : ;=: - | |==| , | -| |==|- | \==\, - \
|==| ,| |==|- , .' |==| , '=' | |==| - _ | |==| ,| /==/ - ,|
|==|- | |==|_ . ,'. \==\ - ,_ / |==| /\ , | |==|- | /==/- /\ - \
/==/. / /==/ /\ , ) '.='. - .' /==/, | |- | /==/. / \==\ _.\=\.-'
`--`-` `--`-`--`--' `--`--'' `--`./ `--` `--`-` `--`
""")
def compare_files(file1, file2):
with open(file1, "rb") as f1, open(file2, "rb") as f2:
# Only Compare first 10 bytes of each file
bytes_to_compare = 10
f1_bytes = f1.read(bytes_to_compare)
f2_bytes = f2.read(bytes_to_compare)
different_bytes = [i+1 for i in range(bytes_to_compare) if f1_bytes[i] != f2_bytes[i]]
if different_bytes:
print(f"Bytes {different_bytes} are different between {file1} and {file2}, maybe {different_bytes} is protected")
else:
print(f"The first {bytes_to_compare} bytes of {file1} and {file2} are the same")
if __name__ == "__main__":
file1 = "global-metadata.dat"
file2 = "2global-metadata.dat"
if not (os.path.isfile(file1) and os.path.isfile(file2)):
print("One or both files do not exist.")
else:
compare_files(file1, file2)
file1 = open("global-metadata.dat", "rb")
file2 = open("2global-metadata.dat", "rb")
data1 = file1.read(10)
data2 = file2.read(10)
if data1 == data2:
print("The first 10 bytes of the files are the same.")
else:
print("The first 10 bytes of the files are different.")
print("Bytes from global-metadata.dat:" + " ".join("{:02x}".format(c) for c in data1))
print("Bytes from 2global-metadata.dat:" + " ".join("{:02x}".format(c) for c in data2))
file1.close()
file2.close()