def export(output: Path): print("Loading files...") tmp_dir = Path(mkdtemp()) if tmp_dir.exists(): try: rmtree(tmp_dir) except (OSError, FileNotFoundError, PermissionError) as err: raise RuntimeError( "There was a problem cleaning the temporary export directory. This may be" " a fluke, so consider restarting BCML and trying again." ) from err link_master_mod(tmp_dir) print("Adding rules.txt...") rules_path = tmp_dir / "rules.txt" mods = util.get_installed_mods() if util.get_settings("wiiu"): rules_path.write_text( "[Definition]\n" "titleIds = 00050000101C9300,00050000101C9400,00050000101C9500\n" "name = Exported BCML Mod\n" "path = The Legend of Zelda: Breath of the Wild/Mods/Exported BCML\n" f'description = Exported merge of {", ".join([mod.name for mod in mods])}\n' "version = 4\n", encoding="utf-8", ) if output.suffix == ".bnp" or output.name.endswith(".bnp.7z"): print("Exporting BNP...") dev.create_bnp_mod( mod=tmp_dir, meta={}, output=output, options={"rstb": { "no_guess": util.get_settings("no_guess") }}, ) else: print("Exporting as graphic pack mod...") x_args = [get_7z_path(), "a", str(output), f'{str(tmp_dir / "*")}'] result: subprocess.CompletedProcess if os.name == "nt": result = subprocess.run( x_args, creationflags=util.CREATE_NO_WINDOW, check=False, capture_output=True, universal_newlines=True, ) else: result = subprocess.run(x_args, check=False, capture_output=True, universal_newlines=True) if result.stderr: raise RuntimeError( f"There was an error exporting your mod(s). {result.stderr}") rmtree(tmp_dir, True)
def create_bnp(self, params): out = self.window.create_file_dialog( webviewb.SAVE_DIALOG, file_types=("BOTW Nano Patch (*.bnp)", "All files (*.*)"), save_filename=util.get_safe_pathname(params["name"]) + ".bnp", ) if not out: raise Exception("canceled") meta = params.copy() del meta["folder"] meta["options"] = params["selects"] del meta["selects"] dev.create_bnp_mod( mod=Path(params["folder"]), output=Path(out if isinstance(out, str) else out[0]), meta=meta, options=params["options"], )