From 057273552b7db1024260e9198862ef4ef66155b5 Mon Sep 17 00:00:00 2001 From: argoneus Date: Sun, 16 Feb 2020 02:24:03 +0100 Subject: [PATCH] fixed up updater --- diva/quest.py | 26 +++++++------------------- divatool.py | 3 +-- utage/translate.py | 7 ++++++- xdudata/update.py | 30 +++++++++++++++--------------- 4 files changed, 29 insertions(+), 37 deletions(-) diff --git a/diva/quest.py b/diva/quest.py index d84e3b2..5a6d27d 100644 --- a/diva/quest.py +++ b/diva/quest.py @@ -18,6 +18,8 @@ def scene_mst(qdb, old_path, dir_in, languages): locations = load_locations(dir_in) + print(locations) + for id, scene in scenes.items(): i = 0 while True: @@ -26,18 +28,14 @@ def scene_mst(qdb, old_path, dir_in, languages): except KeyError as exc: i += 1 if i == len(scene["Parts"]): - raise KeyError( - f"Could not find folder for scene {id}" - ) from exc + raise KeyError(f"Could not find folder for scene {id}") from exc continue break with io.open( os.path.join(old_path, "XduScene.json"), "w", newline="\n" ) as json_file: - json.dump( - scenes, json_file, ensure_ascii=False, indent="\t", sort_keys=True - ) + json.dump(scenes, json_file, ensure_ascii=False, indent="\t", sort_keys=True) for lang in languages: out_dict = {} @@ -66,11 +64,7 @@ def scene_mst(qdb, old_path, dir_in, languages): with io.open(langfile, "w", newline="\n") as lang_file: json.dump( - out_dict, - lang_file, - ensure_ascii=False, - indent="\t", - sort_keys=True, + out_dict, lang_file, ensure_ascii=False, indent="\t", sort_keys=True, ) @@ -80,9 +74,7 @@ def quest_mst(qdb, old_path, languages): with io.open( os.path.join(old_path, "XduQuest.json"), "w", newline="\n" ) as json_file: - json.dump( - quests, json_file, ensure_ascii=False, indent="\t", sort_keys=True - ) + json.dump(quests, json_file, ensure_ascii=False, indent="\t", sort_keys=True) for lang in languages: out_dict = {} @@ -101,11 +93,7 @@ def quest_mst(qdb, old_path, languages): with io.open(langfile, "w", newline="\n") as lang_file: json.dump( - out_dict, - lang_file, - ensure_ascii=False, - indent="\t", - sort_keys=True, + out_dict, lang_file, ensure_ascii=False, indent="\t", sort_keys=True, ) return quests diff --git a/divatool.py b/divatool.py index caf2bef..ec36fed 100755 --- a/divatool.py +++ b/divatool.py @@ -136,7 +136,7 @@ def main(): metavar="", title="subcommand", dest="subcommand" ) parser_xdudata_update = parser_xdudata_subparsers.add_parser( - "update", help="Update an XDUData directory", parents=[global_flag_parser] + "update", help="Update an XDUData directory" ) parser_xdudata_update.add_argument( "CACHE", help="files/ directory from XDU cache", type=str @@ -193,7 +193,6 @@ def main(): args.EXTRACT, script_dir, LANGUAGES, - args.is_global, ) return 0 diff --git a/utage/translate.py b/utage/translate.py index f70fc07..8b70398 100644 --- a/utage/translate.py +++ b/utage/translate.py @@ -20,7 +20,12 @@ def translate_dir(dir_in, tsv_out_dir, json_out_dir, is_global): if len(files) == 0: raise FileNotFoundError("No valid files found in directory: " + dir_in) - ptrans = partial(translate_file, tsv_out_dir=tsv_out_dir, json_out_dir=json_out_dir) + ptrans = partial( + translate_file, + tsv_out_dir=tsv_out_dir, + json_out_dir=json_out_dir, + is_global=is_global, + ) with Pool() as p: p.map(ptrans, files) diff --git a/xdudata/update.py b/xdudata/update.py index 6924b13..b659c3f 100644 --- a/xdudata/update.py +++ b/xdudata/update.py @@ -12,28 +12,21 @@ from glob import glob def update_all( - cache_dir, - update_dir, - translation_dir, - extract_dir, - script_dir, - languages, - is_global, + cache_dir, update_dir, translation_dir, extract_dir, script_dir, languages, ): print("Cleaning cache") cleanup_cache(cache_dir) print("Copying images") - # copy_images(cache_dir, update_dir) + copy_images(cache_dir, update_dir) print("Processing TSV files") - # TODO - # update_tsv(cache_dir, update_dir, translation_dir, languages, is_global) + update_tsv(cache_dir, update_dir, extract_dir, translation_dir, languages) print("Processing Quest Json files") - # diva.quest.update_missions(cache_dir, translation_dir, languages) + diva.quest.update_missions(extract_dir, translation_dir, languages) - # this code isn't going to run on windows (it will in WSL though) because i need to rewrite it + # this code isn't going to run on windows (it is in WSL though) because i need to rewrite it # it just calls my zsh tools and generates it that way, need to replace them # with real python or something @@ -92,7 +85,7 @@ def update_all( ) -def update_tsv(cache_dir, update_dir, translation_dir, languages, is_global): +def update_tsv(cache_dir, update_dir, extract_dir, translation_dir, languages): utage_tmp = tempfile.mkdtemp() copy_tree(os.path.join(cache_dir, "Common/Asset/Utage"), utage_tmp) utage.crypt.crypt_dir( @@ -104,13 +97,20 @@ def update_tsv(cache_dir, update_dir, translation_dir, languages, is_global): except: pass + # copy over files for the quest updater + copy_tree(utage_tmp, os.path.join(extract_dir, "Common/Asset/Utage")) + shutil.copy2(os.path.join(cache_dir, "QuestMst.db"), extract_dir) + shutil.copy2(os.path.join(cache_dir, "QuestSceneMst.db"), extract_dir) + shutil.copy2(os.path.join(cache_dir, "QuestPartMst.db"), extract_dir) + shutil.copy2(os.path.join(cache_dir, "ResourceEntry.db"), extract_dir) + utage.translate.translate_dir( utage_tmp, os.path.join(update_dir, "Utage"), os.path.join(translation_dir, "Missions"), - is_global, + False, ) - utage.names.update_names(utage_tmp, translation_dir, languages) + utage.names.update_names(utage_tmp, translation_dir, languages, False) copy_tree(os.path.join(utage_tmp, "Diva"), os.path.join(update_dir, "Utage/Diva")) remove_tree(utage_tmp)