mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2026-07-12 17:31:06 +00:00
i don't know :(
This commit is contained in:
parent
d2ff9b626a
commit
2578f9ec6f
2 changed files with 12 additions and 9 deletions
|
|
@ -5,7 +5,7 @@ LANG_DIR = "./lang/"
|
|||
def pass_string(optionstr): return optionstr
|
||||
|
||||
def open_lang(name):
|
||||
parser = configparser.ConfigParser(interpolation=None)
|
||||
parser = configparser.ConfigParser()
|
||||
parser.optionxform = pass_string
|
||||
parser.read(LANG_DIR + name, "utf-8")
|
||||
return parser
|
||||
|
|
|
|||
|
|
@ -1,22 +1,25 @@
|
|||
import configparser
|
||||
import os
|
||||
def pass_string(optionstr): return optionstr
|
||||
|
||||
english = configparser.ConfigParser()
|
||||
english.read("lang/English.ini", encoding="utf-8")
|
||||
english.optionxform = pass_string
|
||||
english.read("lang/English.ini", "utf-8")
|
||||
|
||||
# get the sections and keys from the English INI file
|
||||
english_sections = [section.upper() for section in english.sections()]
|
||||
english_sections = english.sections()
|
||||
english_keys = {
|
||||
section.upper(): [key.upper() for key in english.options(section)]
|
||||
section: english.options(section)
|
||||
for section in english_sections
|
||||
}
|
||||
|
||||
# function to compare an INI file against the English INI file
|
||||
def compare_ini_file(file_path):
|
||||
config = configparser.ConfigParser()
|
||||
config.read(file_path, encoding="utf-8")
|
||||
config.optionxform = pass_string
|
||||
config.read(file_path, "utf-8")
|
||||
|
||||
config_sections = [section.upper() for section in config.sections()]
|
||||
config_sections = config.sections()
|
||||
|
||||
missing_sections = set(english_sections) - set(config_sections)
|
||||
extra_sections = set(config_sections) - set(english_sections)
|
||||
|
|
@ -24,7 +27,7 @@ def compare_ini_file(file_path):
|
|||
missing_keys = {}
|
||||
for section in english_sections:
|
||||
if section in config_sections:
|
||||
section_keys = [key.upper() for key in config.options(section)]
|
||||
section_keys = config.options(section)
|
||||
missing_keys[section] = set(english_keys[section]) - set(section_keys)
|
||||
|
||||
return missing_sections, extra_sections, missing_keys
|
||||
|
|
@ -38,7 +41,7 @@ for filename in os.listdir("lang"):
|
|||
|
||||
print(f"\nComparing {filename}:")
|
||||
if not missing_sections and not extra_sections and not any(missing_keys.values()):
|
||||
print(f"{filename} is matching to English.ini.")
|
||||
print(f"{filename}: matching!")
|
||||
else:
|
||||
if missing_sections:
|
||||
print(f"Missing sections: {', '.join(missing_sections)}")
|
||||
|
|
@ -46,4 +49,4 @@ for filename in os.listdir("lang"):
|
|||
print(f"Extra sections: {', '.join(extra_sections)}")
|
||||
for section, keys in missing_keys.items():
|
||||
if keys:
|
||||
print(f"Missing keys in section '{section}': {', '.join(keys)}")
|
||||
print(f"[{section}]: Missing{', '.join(keys)}")
|
||||
Loading…
Add table
Reference in a new issue