-
Notifications
You must be signed in to change notification settings - Fork 0
/
spoiler_log_only.py
executable file
·52 lines (29 loc) · 1.19 KB
/
spoiler_log_only.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python3
from argparse import ArgumentParser, Namespace
from typing import List
from shop_randomiser import generate_spoiler_log, load_rom_data, write_spoiler_log
import os
ff5_bytes: List[int] = []
def parse_arguments() -> str:
parser: ArgumentParser = ArgumentParser()
parser.add_argument("-i", "--input_rom", type=str, metavar="input_rom", required=True)
args: Namespace = parser.parse_args()
input_rom: str = args.input_rom
if not os.path.isabs(input_rom):
input_rom = os.path.join(os.getcwd(), input_rom)
if not os.path.exists(input_rom):
print("{} does not seem to exist. Aborting.".format(input_rom))
exit(-1)
return input_rom
def main():
input_rom: str = parse_arguments()
global ff5_bytes
ff5_bytes = load_rom_data(rom_path=input_rom)
spoiler_log: List[str] = generate_spoiler_log(ff5_bytes_ro=ff5_bytes)
write_spoiler_log(spoiler_log=spoiler_log, output_file_path="{}.spoiler_log.txt".format(input_rom))
def load_rom_data(rom_path: str) -> List[int]:
assert os.path.isfile(rom_path)
with open(rom_path, "rb") as f:
return [b for b in f.read()]
if __name__ == "__main__":
main()