From: Simon Cozens Date: Mon, 19 Aug 2024 15:09:58 +0000 (+0100) Subject: Assert uniqueness of all IDs X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=be426cd01d42047ff878f8351f43acbe52bf5333;p=thirdparty%2Fgoogle%2Ffonts.git Assert uniqueness of all IDs --- diff --git a/Lib/gflanguages/__init__.py b/Lib/gflanguages/__init__.py index c7b0bc6181..0754d6c135 100644 --- a/Lib/gflanguages/__init__.py +++ b/Lib/gflanguages/__init__.py @@ -44,6 +44,7 @@ def LoadLanguages(base_dir=DATA_DIR): for textproto_file in glob.iglob(os.path.join(languages_dir, "*.textproto")): with open(textproto_file, "r", encoding="utf-8") as f: language = text_format.Parse(f.read(), languages_public_pb2.LanguageProto()) + assert language.id not in langs, f"Duplicate language id: {language.id}" langs[language.id] = language return langs @@ -57,6 +58,7 @@ def LoadScripts(base_dir=DATA_DIR): for textproto_file in glob.iglob(os.path.join(scripts_dir, "*.textproto")): with open(textproto_file, "r", encoding="utf-8") as f: script = text_format.Parse(f.read(), languages_public_pb2.ScriptProto()) + assert script.id not in scripts, f"Duplicate script id: {script.id}" scripts[script.id] = script return scripts @@ -70,6 +72,7 @@ def LoadRegions(base_dir=DATA_DIR): for textproto_file in glob.iglob(os.path.join(regions_dir, "*.textproto")): with open(textproto_file, "r", encoding="utf-8") as f: region = text_format.Parse(f.read(), languages_public_pb2.RegionProto()) + assert region.id not in regions, f"Duplicate region id: {region.id}" regions[region.id] = region return regions