forked from ArchipelagoMW/Archipelago
- Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathPatch.py
More file actions
Latest commit
35 lines (26 loc) · 1.04 KB
/
Copy pathPatch.py
File metadata and controls
35 lines (26 loc) · 1.04 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
from __future__ importannotations
importos
importsys
fromtypingimportTuple, Optional, TypedDict
if__name__=="__main__":
importModuleUpdate
ModuleUpdate.update()
fromworlds.FilesimportAutoPatchRegister, APAutoPatchInterface
classRomMeta(TypedDict):
server: str
player: Optional[int]
player_name: str
defcreate_rom_file(patch_file: str) ->Tuple[RomMeta, str]:
auto_handler=AutoPatchRegister.get_handler(patch_file)
ifauto_handler:
handler: APAutoPatchInterface=auto_handler(patch_file)
target=os.path.splitext(patch_file)[0]+handler.result_file_ending
handler.patch(target)
return {"server": handler.server,
"player": handler.player,
"player_name": handler.player_name}, target
raiseNotImplementedError(f"No Handler for {patch_file} found.")
if__name__=="__main__":
forfileinsys.argv[1:]:
meta_data, result_file=create_rom_file(file)
print(f"Patch with meta-data {meta_data} was written to {result_file}")