From 693bf76306da3ad195c447cb257147a869947de5 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 8 Feb 2024 19:00:00 +0100 Subject: Minor tidy-up of CldrAccess.__enumMap: revise comment, modernize code A comment dated from when variables misleadingly named language_list, script_list and country_list actually held mappings not lists; they've been renamed to s/list/map/ a while back, so rephrase. Use a dict-comprehension rather than the somewhat lisp-ier invocation of the dict constructor on an iterator over pairs. Change-Id: Ibcb97122434122dbb1dcb0f621aae02b25a4e1fa Reviewed-by: Cristian Maureira-Fredes --- util/locale_database/cldr.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'util') diff --git a/util/locale_database/cldr.py b/util/locale_database/cldr.py index a725526dbf..345fc50f5f 100644 --- a/util/locale_database/cldr.py +++ b/util/locale_database/cldr.py @@ -636,15 +636,15 @@ enumdata.py (keeping the old name as an alias): def __enumMap(self, key, cache = {}): if not cache: cache['variant'] = {'': (0, 'This should never be seen outside ldml.py')} - # They're not actually lists: mappings from numeric value - # to pairs of full name and short code. What we want, in - # each case, is a mapping from code to the other two. + # They're mappings from numeric value to pairs of full + # name and short code. What we want, in each case, is a + # mapping from code to the other two. from enumdata import language_map, script_map, territory_map for form, book, empty in (('language', language_map, 'AnyLanguage'), ('script', script_map, 'AnyScript'), ('territory', territory_map, 'AnyTerritory')): - cache[form] = dict((pair[1], (num, pair[0])) - for num, pair in book.items() if pair[0] != 'C') + cache[form] = {pair[1]: (num, pair[0]) + for num, pair in book.items() if pair[0] != 'C'} # (Have to filter out the C locale, as we give it the # same (all space) code as AnyLanguage, whose code # should probably be 'und' instead.) -- cgit v1.2.3