fixed newlines and other windows stuff

This commit is contained in:
argoneus 2020-05-15 23:13:38 +02:00
parent 1f26e8a9ce
commit c15343b4b8
4 changed files with 32 additions and 24 deletions

View file

@ -31,7 +31,7 @@ def scene_mst(qdb, old_path, dir_in, languages):
break
with io.open(
os.path.join(old_path, "XduScene.json"), "w", newline="\n"
os.path.join(old_path, "XduScene.json"), "w", encoding="utf-8"
) as json_file:
json.dump(scenes, json_file, ensure_ascii=False, indent="\t", sort_keys=True)
@ -56,11 +56,11 @@ def scene_mst(qdb, old_path, dir_in, languages):
langfile = os.path.join(old_path, f"XduSceneNames_{lang}.json")
if os.path.isfile(langfile):
with open(langfile, "r") as lang_file:
with open(langfile, "r", encoding="utf-8") as lang_file:
lang_dict = json.load(lang_file)
out_dict.update(lang_dict)
with io.open(langfile, "w", newline="\n") as lang_file:
with io.open(langfile, "w", encoding="utf-8") as lang_file:
json.dump(
out_dict, lang_file, ensure_ascii=False, indent="\t", sort_keys=True,
)
@ -70,7 +70,7 @@ def quest_mst(qdb, old_path, languages):
quests = qdb.get_quests()
with io.open(
os.path.join(old_path, "XduQuest.json"), "w", newline="\n"
os.path.join(old_path, "XduQuest.json"), "w", encoding="utf-8"
) as json_file:
json.dump(quests, json_file, ensure_ascii=False, indent="\t", sort_keys=True)
@ -85,11 +85,11 @@ def quest_mst(qdb, old_path, languages):
langfile = os.path.join(old_path, f"XduQuestNames_{lang}.json")
if os.path.isfile(langfile):
with open(langfile, "r") as lang_file:
with open(langfile, "r", encoding="utf-8") as lang_file:
lang_dict = json.load(lang_file)
out_dict.update(lang_dict)
with io.open(langfile, "w", newline="\n") as lang_file:
with io.open(langfile, "w", encoding="utf-8") as lang_file:
json.dump(
out_dict, lang_file, ensure_ascii=False, indent="\t", sort_keys=True,
)
@ -108,7 +108,7 @@ def load_locations(dir_in):
raise FileNotFoundError("Ya didn't decrypt the files dummy")
for scenario in settings:
with open(scenario, "r") as tsv_file:
with open(scenario, "r", encoding="utf-8") as tsv_file:
tsv = csv.DictReader(tsv_file, delimiter="\t", quotechar='"')
for row in tsv:
tokens = row["FileName"].split("/")