fixed up updater

This commit is contained in:
argoneus 2020-02-16 02:24:03 +01:00
parent ecde988fd9
commit fe9741a20a
4 changed files with 29 additions and 37 deletions

View file

@ -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

View file

@ -136,7 +136,7 @@ def main():
metavar="<command>", 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

View file

@ -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)

View file

@ -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)