-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdbg.py
38 lines (31 loc) · 1.1 KB
/
dbg.py
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
def read_debug():
import os
root_folder = os.path.realpath(os.path.dirname(__file__))
func_dict = {}
dbg_path = os.path.join(root_folder, "debug.txt")
with open(dbg_path, 'r') as f:
text_lines = f.readlines()
for x in text_lines:
new_text = x[:-1].split(" ", maxsplit=1)
try:
func_dict[int(new_text[0], 16)] = new_text[1].replace("\"", "")
except:
pass
return func_dict
checksum_dbg = read_debug()
def add_extra(qb_key, text):
import os
global checksum_dbg
root_folder = os.path.realpath(os.path.dirname(__file__))
if int(qb_key, 16) not in checksum_dbg:
file_path = os.path.join(root_folder, "debug_extra.txt")
with open(file_path, 'a') as f:
f.write(f'\n{qb_key} "{text}"')
# checksum_dbg[int(qb_key, 16)] = text
if __name__ == "__main__":
import CRC
for x in checksum_dbg.keys():
str_check = checksum_dbg[x]
dbg_check = hex(int(CRC.QBKey(checksum_dbg[x]), 16))
if dbg_check != hex(int(x, 16)):
print(f"{x} is not equal to {checksum_dbg[x]}")