sorting out zsh script calling and folder names
This commit is contained in:
parent
d761d12c63
commit
77e78a73eb
6 changed files with 79 additions and 51 deletions
|
|
@ -9,7 +9,7 @@ from glob import glob
|
|||
from multiprocessing import Pool
|
||||
|
||||
|
||||
def update_names(dir_in, old_path, languages):
|
||||
def update_names(dir_in, old_path, languages, is_global):
|
||||
names = extract_names(dir_in)
|
||||
|
||||
# we have to update japanese like the rest because CustomData exists
|
||||
|
|
@ -30,11 +30,7 @@ def update_names(dir_in, old_path, languages):
|
|||
langfile, "w", newline="\n"
|
||||
) as lang_file: # you're using git right
|
||||
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,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -101,8 +97,6 @@ def read_mission(tsv_path, char_names, char_sets):
|
|||
if row["Command"] and row["Command"].startswith("//"):
|
||||
continue
|
||||
if row["Text"] and row["Arg1"]:
|
||||
if (row["Arg1"] not in char_names) and (
|
||||
row["Arg1"] not in char_sets
|
||||
):
|
||||
if (row["Arg1"] not in char_names) and (row["Arg1"] not in char_sets):
|
||||
new_names.add(row["Arg1"])
|
||||
return new_names
|
||||
|
|
|
|||
|
|
@ -10,26 +10,22 @@ from glob import glob
|
|||
from multiprocessing.pool import Pool
|
||||
|
||||
|
||||
def translate_dir(dir_in, tsv_out_dir, json_out_dir):
|
||||
def translate_dir(dir_in, tsv_out_dir, json_out_dir, is_global):
|
||||
files = [
|
||||
f
|
||||
for f in glob(
|
||||
os.path.join(dir_in, "**/Scenario/*.tsv"), recursive=True
|
||||
)
|
||||
for f in glob(os.path.join(dir_in, "**/Scenario/*.tsv"), recursive=True)
|
||||
if "{os.path.sep}Diva{os.path.sep}" not in f
|
||||
]
|
||||
|
||||
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)
|
||||
with Pool() as p:
|
||||
p.map(ptrans, files)
|
||||
|
||||
|
||||
def translate_file(file_in, tsv_out_dir, json_out_dir):
|
||||
def translate_file(file_in, tsv_out_dir, json_out_dir, is_global):
|
||||
try:
|
||||
if not file_in.endswith(".tsv"):
|
||||
raise ValueError("Invalid File Type for {}".format(file_in))
|
||||
|
|
@ -49,9 +45,7 @@ def translate_file(file_in, tsv_out_dir, json_out_dir):
|
|||
tsv_out_dir, event_folder, "Scenario", "{}_t.tsv".format(id_num)
|
||||
)
|
||||
json_output_path = os.path.join(
|
||||
json_out_dir,
|
||||
event_folder,
|
||||
"{}_translations_jpn.json".format(id_num),
|
||||
json_out_dir, event_folder, "{}_translations_jpn.json".format(id_num),
|
||||
)
|
||||
|
||||
# need to create output paths and avoid races when threading
|
||||
|
|
@ -90,11 +84,7 @@ def translate_file(file_in, tsv_out_dir, json_out_dir):
|
|||
with io.open(json_output_path, "w", newline="\n") as json_out:
|
||||
# we don't want to sort these because they're _1, ..., _10, etc
|
||||
json.dump(
|
||||
json_str,
|
||||
json_out,
|
||||
ensure_ascii=False,
|
||||
indent="\t",
|
||||
sort_keys=False,
|
||||
json_str, json_out, ensure_ascii=False, indent="\t", sort_keys=False,
|
||||
)
|
||||
|
||||
except Exception:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue