Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_mod_diff(self, mod: util.BcmlMod):
diff = {}
if self.is_mod_logged(mod):
util.dict_merge(
diff, json.loads((mod.path / "logs" / self._log_name).read_text("utf-8"))
)
for opt in {d for d in (mod.path / "options").glob("*") if d.is_dir()}:
if (opt / "logs" / self._log_name).exists():
util.dict_merge(
diff, json.loads((opt / "logs" / self._log_name).read_text("utf-8"))
)
return diff
actor_path = (util.get_master_modpack_dir() / 'content' /
'Actor' / 'ActorInfo.product.sbyml')
if not mods:
print('No actor info merging necessary.')
if actor_path.exists():
actor_path.unlink()
return
print('Loading modded actor info...')
modded_actors = {}
loader = yaml.CSafeLoader
yaml_util.add_constructors(loader)
for mod in mods:
with (mod.path / 'logs' / 'actorinfo.yml').open('r', encoding='utf-8') as a_file:
entries = yaml.load(a_file, Loader=loader)
util.dict_merge(modded_actors, entries, overwrite_lists=True)
if verbose:
print(f'Loaded {len(entries)} entries from {mod.name}')
del entries
print('Loading unmodded actor info...')
actorinfo = get_stock_actorinfo()
print('Merging changes...')
for actor_hash, actor_info in modded_actors.items():
if actor_hash in actorinfo['Hashes']:
idx = actorinfo['Hashes'].index(actor_hash)
util.dict_merge(actorinfo['Actors'][idx],
actor_info, overwrite_lists=True)
if verbose:
print(f' Updated entry for {actorinfo["Actors"][idx]}')
else:
actorinfo['Hashes'].append(actor_hash)
def get_mod_diff(self, mod: util.BcmlMod):
diff = oead.byml.Hash()
if self.is_mod_logged(mod):
diff = oead.byml.from_text(
(mod.path / "logs" / self._log_name).read_text("utf-8")
)
for opt in {d for d in (mod.path / "options").glob("*") if d.is_dir()}:
if (opt / "logs" / self._log_name).exists():
util.dict_merge(
diff,
oead.byml.from_text(
(opt / "logs" / self._log_name).read_text("utf-8")
),
overwrite_lists=True,
)
return diff
def consolidate_diffs(self, diffs):
consolidated = {}
for diff in diffs:
util.dict_merge(consolidated, diff)
return consolidated
def get_mod_diff(self, mod: BcmlMod):
diffs = {}
if self.is_mod_logged(mod):
util.dict_merge(
diffs,
oead.byml.from_text(
(mod.path / "logs" / self._log_name).read_text(encoding="utf-8")
),
overwrite_lists=True,
)
for opt in {d for d in (mod.path / "options").glob("*") if d.is_dir()}:
if (opt / "logs" / self._log_name).exists():
util.dict_merge(
diffs,
oead.byml.from_text(
(opt / "logs" / self._log_name).read_text("utf-8")
),
overwrite_lists=True,
)
return diffs
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)
def get_mod_diff(self, mod: util.BcmlMod):
diff = {}
if self.is_mod_logged(mod):
util.dict_merge(
diff, json.loads((mod.path / "logs" / self._log_name).read_text("utf-8"))
)
for opt in {d for d in (mod.path / "options").glob("*") if d.is_dir()}:
if (opt / "logs" / self._log_name).exists():
util.dict_merge(
diff, json.loads((opt / "logs" / self._log_name).read_text("utf-8"))
)
return diff
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,
)
print("Saving status effect merge log...")
merged_effects.parent.mkdir(parents=True, exist_ok=True)
merged_effects.write_bytes(effect_bytes)