patcher.py (view raw)
1#!/usr/bin/python3
2import tkinter as tk
3import os
4from hashlib import md5
5from Gui import PatcherApp
6
7m12_md5 = 'f41e36204356974c94fabf7d144dd32a'
8tools_path = os.path.join('.', 'tools')
9alt_path = os.path.join(tools_path, 'alt')
10
11def check_rom(filename):
12 with open(filename, 'rb') as f:
13 file_hash = md5()
14 while chunk := f.read(8192):
15 file_hash.update(chunk)
16
17 return file_hash.hexdigest() == m12_md5
18
19if __name__ == "__main__":
20
21 if not os.path.isdir(alt_path):
22 print('\nErrore: รจ necessario estrarre l\'archivio.')
23 exit()
24
25 baserom = None
26 for file in os.listdir('.'):
27 if file.endswith('.gba'):
28 filename = os.path.join('.', file)
29 if(check_rom(filename)):
30 baserom = filename
31
32 root = tk.Tk()
33 app = PatcherApp(root)
34 app.run()