Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
(
str(util.get_game_file("Pack/Bootup.pack"))
+ "//Ecosystem/StatusEffectList.sbyml"
),
unyaz=False,
)
util.inject_file_into_sarc(
"Ecosystem/StatusEffectList.sbyml",
stock_effects,
"Pack/Bootup.pack",
)
del stock_effects
except FileNotFoundError:
pass
return
util.vprint("All status effect diffs:")
util.vprint(diffs)
effects = get_stock_effects()
util.dict_merge(effects, diffs, overwrite_lists=True)
del diffs
print("Writing new effects list...")
effect_bytes = oead.byml.to_binary(
oead.byml.Array([effects]), big_endian=util.get_settings("wiiu")
)
del effects
util.inject_file_into_sarc(
"Ecosystem/StatusEffectList.sbyml",
util.compress(effect_bytes),
"Pack/Bootup.pack",
create_sarc=True,
def install_mod(self, params: dict):
util.vprint(params)
with Pool(maxtasksperchild=1000) as pool:
selects = (
params["selects"] if "selects" in params and params["selects"] else {}
)
mods = [
install.install_mod(
Path(m),
options=params["options"],
selects=selects.get(m, None),
pool=pool,
)
for m in params["mods"]
]
util.vprint(f"Installed {len(mods)} mods")
print(f"Installed {len(mods)} mods")
try:
install.refresh_merges()
print("Install complete")
except Exception: # pylint: disable=broad-except
pool.terminate()
raise
except ValueError:
new_bytes = file_bytes
del file_bytes
print(f"Deep merging file {file} failed. No changes were made.")
else:
raise ValueError(f"{file} is not a SARC or AAMP file.")
new_bytes = new_bytes if not yazd else util.compress(new_bytes)
output_file = util.get_master_modpack_dir() / file
if base_file == output_file:
output_file.unlink()
output_file.parent.mkdir(parents=True, exist_ok=True)
output_file.write_bytes(new_bytes)
del new_bytes
if magic == b"SARC":
util.vprint(f"Finished patching files inside {file}")
else:
util.vprint(f"Finished patching {file}")
return util.get_canon_name(file), failures
for diff in pool.imap_unordered(_convert_text_log, logs_path.glob("texts_*.yml")):
diffs.update(diff)
fails = set()
for text_pack in logs_path.glob("newtexts_*.sarc"):
lang = text_pack.stem[9:]
sarc = oead.Sarc(text_pack.read_bytes())
for file in sarc.get_files():
if lang not in diffs:
diffs[lang] = {}
try:
diffs[lang].update({file.name: read_msbt(bytes(file.data))["entries"]})
except RuntimeError:
print(f"Warning: {file.name} could not be processed and will not be used")
fails.add(file.name)
continue
util.vprint(f"{len(fails)} text files failed to process:\n{fails}")
text_pack.unlink()
(logs_path / "texts.json").write_text(
json.dumps(diffs, ensure_ascii=False, indent=2), encoding="utf-8"
)
def get_mods(self, params):
if not params:
params = {"disabled": False}
mods = [mod.to_json() for mod in util.get_installed_mods(params["disabled"])]
util.vprint(mods)
return mods
def get_mod_info(self, params):
mod = BcmlMod.from_json(params["mod"])
util.vprint(mod)
img = ""
try:
img = base64.b64encode(mod.get_preview().read_bytes()).decode("utf8")
except (KeyError, FileNotFoundError):
pass
return {
"changes": [
m.NAME.upper() for m in mergers.get_mergers() if m().is_mod_logged(mod)
],
"desc": mod.description,
"date": mod.date,
"processed": (mod.path / ".processed").exists(),
"image": img,
"url": mod.url,
}
def consolidate_diffs(self, diffs: list):
all_diffs = {}
for diff in diffs:
util.dict_merge(all_diffs, diff, overwrite_lists=True)
util.vprint("All actor info diffs:")
util.vprint(oead.byml.to_text(all_diffs))
return oead.byml.Hash(all_diffs)
for item, prob in {
(i, p)
for i, p in contents["items"].items()
if i in ref_table[table]["items"]
}:
if prob == ref_table[table]["items"][item]:
drop_table[table]["items"][item] = util.UNDERRIDE
del ref_table
except (
FileNotFoundError,
oead.InvalidDataError,
AttributeError,
RuntimeError,
ValueError,
):
util.vprint(f"Could not load stock {file}")
return {file: drop_table}