performance improvements and small adjustments

This commit is contained in:
Fabian Dill
2020-03-10 00:38:29 +01:00
parent 4cb5af19d6
commit a29f93045e
6 changed files with 39 additions and 25 deletions

View File

@@ -3,7 +3,7 @@ import yaml
import os
import lzma
import hashlib
import logging
from typing import Tuple
import Utils
from Rom import JAP10HASH, read_rom
@@ -45,12 +45,13 @@ def create_patch_file(rom_file_to_patch: str, server: str = "") -> str:
return target
def create_rom_file(patch_file) -> dict:
def create_rom_file(patch_file) -> Tuple[dict, str]:
data = Utils.parse_yaml(lzma.decompress(load_bytes(patch_file)).decode("utf-8-sig"))
patched_data = bsdiff4.patch(get_base_rom_bytes(), data["patch"])
with open(os.path.splitext(patch_file)[0] + ".sfc", "wb") as f:
target = os.path.splitext(patch_file)[0] + ".sfc"
with open(target, "wb") as f:
f.write(patched_data)
return data["meta"]
return data["meta"], target
def load_bytes(path: str):