def load_region_key_names(): aliases = load_aliases("data/ALIASES") regions = load_regions() regions.update(load_subregions()) region_keys_names = {} region_keys = sorted(regions.keys()) for k in region_keys: # If this uses another flag, skip if k in aliases: continue if 'Description' in regions[k].keys(): region_keys_names[k] = regions[k]['Description'] else: region_keys_names[k] = regions[k]['Subdivision name'] return region_keys_names
def load_region_urls(): aliases = load_aliases("ALIASES") aliases_wp = load_aliases("ALIASES-WP") regions = load_regions() keys = sorted(regions.keys()) urls = {} for k in keys: # If this uses another flag, skip if k in aliases: continue s = regions[k]['Description'] # Apply Wikipedia-specific mappings s = aliases_wp.get(s, s) s = s.replace(' ', '_') url = "https://commons.wikimedia.org/wiki/File:Flag_of_%s.svg" % s urls[k] = url return urls