def get_country_code(country_name): """根据指定的国家, 返回Pygal使用的两个字母的国别码""" for country_code in sorted(COUNTRIES.keys()): for code, name in COUNTRIES.items(): if name == country_name: return code # 如果没有找到指定的国家, 就返回None return None
def get_country_code(country_name): #根据指定的国家,返回pygal使用的两个字母的国别码 for code, name in COUNTRIES.items(): if name == country_name: return code # If the country wasn't found, return None. if country_name == 'Korea, Republic of': return 'kr' elif country_name == "Korea, Democratic People's Republic of": return 'kp' elif country_name == 'Bolivia, Plurinational State of': return 'bo' elif country_name == 'Venezuela, Bolivarian Republic of': return 've' elif country_name == 'Yemen': return 'ye' elif country_name == 'Congo, the Democratic Republic of the': return 'cd' elif country_name == 'Tanzania, United Republic of': return 'tz' elif country_name == 'Iran, Islamic Republic of': return 'ir' elif country_name == 'Egypt': return 'eg' else: return None '''
def get_country_code(country_name): '''Return the pygal 2-digit country code for the given country''' for code, name in COUNTRIES.items(): if name == country_name: return code elif country_name == 'Andorra': return 'ad' elif country_name == 'Bolivia': return 'bo' elif country_name == 'Dominica': return 'do' elif country_name == 'Egypt, Arab Rep.': return 'eg' elif country_name == 'Hong Kong SAR, China': return 'hk' elif country_name == 'Iran, Islamic Rep.': return 'ir' elif country_name == 'Korea, Dem. Rep.': return 'kp' elif country_name == 'Korea, Rep': return 'kr' elif country_name == 'Kyrgyz Republic': return 'kg' elif country_name == 'LAO PDR': return 'la' elif country_name == 'Libya': return 'ly' elif country_name == 'Macedonia, FYR': return 'mk' elif country_name == 'Yemen, Rep.': return 'ye' #If country not found return None. return None
def get_country_code(country_name): """Return the 2-digit code for a country""" for code, name in COUNTRIES.items(): if name == country_name.title(): return code #Return None if no country found return None
def get_country_code(Country_name): """Return the Pygal 2-digit country code for the given country.""" for code, name in COUNTRIES.items(): if name == Country_name: return code #if country not found , return none return None
def get_country_code(country_name): """Return the Pygal 2-digit country code for the given country.""" for code, name in COUNTRIES.items(): if name == country_name: return code if country_name == 'Yemen, Rep.': return 'ye' elif country_name == 'Venezuela, Bolivarian Republic of': return 've' elif country_name == 'Boliva, Plurinational State of': return 'bo' elif country_name == 'Congo': return 'cg' elif country_name == 'Congo, Democratic Republic of the': return 'cd' elif country_name == 'Tanzania, United Republic of': return 'tz' elif country_name == 'Uganda': return 'tz' elif country_name == 'Libyan, Arab Jamahiriya': return 'ly' elif country_name == 'Eypgt': return 'eg' elif country_name == 'Antartica': return 'aq' elif country_name == "Korea, Democractic People's Republic of": return 'kp' elif country_name == 'Korea, Republic of': return 'kr' # If the country wasn't found, return None. return None
def code_search(input): """A function to search through Pygal's country code file and return the code""" for code, name in COUNTRIES.items(): if input == name: return code # Specific exceptions for countries with difficult names if input == 'Congo, Dem. Rep.': return 'cd' elif input == 'Libya': return 'ly' elif input == 'Congo, Rep.': return 'cg' elif input == 'Tanzania': return 'tz' elif input == 'Egypt, Arab Rep.': return 'eg' elif input == 'Iran, Islamic Rep.': return 'ir' elif input == 'Bolivia': return 'bo' elif input == 'Venezuela, RB': return 've' elif input == 'Yemen, Rep.': return 'ye' # Returning none if the country of interest was not found return None
def get_country_code(country_name): """根据指定的国家,返回Pygal使用的两个字母的国别码""" for code, name in COUNTRIES.items(): if name == country_name: return code # 如果没有找到指定的国家,就返回None return None
def get_country_code(country_name): for code, name in COUNTRIES.items(): if name == country_name: return code if country_name == "Yemen, Rep.": return 'ye' if country_name == "Iran, Islamic Rep.": return 'ir' if country_name == "Kyrgyz Republic": return 'kg' if country_name == 'Moldova': return 'md' if country_name == 'Slovak Republic': return 'sk' if country_name == 'Venezuela, RB': return 've' if country_name == 'Bolivia': return 'bo' if country_name == 'Libya': return 'ly' if country_name == 'Egypt, Arab Rep.': return 'eg' if country_name == 'Korea, Rep.': return 'kr' if country_name == 'Tanzania': return 'tz' if country_name == 'Congo, Dem. Rep.': return 'cd' if country_name == 'Congo, Rep.': return 'cg' if country_name == 'Cabo Verde': return 'cv' if country_name == 'Vietnam': return 'vn' if country_name == 'Lao PDR': return 'la' if country_name == 'West Bank and Gaza': return 'ps' if country_name == 'Gambia, The': return 'gm' if country_name == 'Macedonia, FYR': return 'mk' if country_name == 'Hong Kong SAR, China': return 'hk' # Если страна не найдена, вернуть None return None
def get_country_code(country_name): """Return the Pygal 2-digit country code for the given country.""" for code, name in COUNTRIES.items(): if name == country_name: return code # If the country wasn't found, return None. return None
def get_country_code(country_name): """根据指定的国家,返回Pygal使用的两个字母的国别码""" for code, name in COUNTRIES.items(): if name == country_name: return code # 若没找到返回None return None
def get_country_code(country_name): '''Возвращает для заданной страны ее код в Pygal, состоящий из двух букв''' for code, name in COUNTRIES.items(): if name == country_name: return code # если сторана не неайдена, вернуть None return None
def get_country_code(country_name): '''Return the Pygal 2-digit country code for a given country.''' for code, name in COUNTRIES.items(): if name == country_name: return code # if the name isn't found, return None: return None
def get_country_code(country_name): """Return the Pygal 2-digit country code for the given country.""" for code, name in COUNTRIES.items(): if country_name == name: return code return None
def get_country_code(country_name): """Devolve o código de duas letras do Pygal para um país, dado o seu nome.""" for code, name in COUNTRIES.items(): if name == country_name: return code # Se o país não for encontrado, devolve None return None
def get_country_code(country_name): """Return 2-digit country code for a country name""" for code, name in COUNTRIES.items(): if name == country_name: return code return None
def get_country_code(country): """Return the 2-digit pygal code given a country.""" for code, name in COUNTRIES.items(): if name == country: return code # If the country wasn't found in the list from pygal.maps.world return None
def get_country_code(country_name): '''return the 2 digit country code''' for code, name in COUNTRIES.items(): if name == country_name: return code #if the country isnt found return none return None
def get_country_code(country_name): #根据指定的国家,返回Pygal使用的两个字母的国别码 for code, name in COUNTRIES.items(): if name == country_name: return code # 如果没有找到指定的国家,就返回None return None
def createMap(countryCode, debug=False): print(countryCode) country = COUNTRIES[countryCode] everyOtherCountry = list(COUNTRIES.keys()) everyOtherCountry.remove(countryCode) custom_style = Style(show_legend=False, colors=('#000000', '#BBBBBB')) worldmap = pygal.maps.world.World(show_legend=False, show_title=False, style=custom_style) worldmap.add( country, [countryCode], ) worldmap.add( 'everyone else', everyOtherCountry, ) if debug: worldmap.render_in_browser() else: worldmap.render_to_file('%s/%s/map.svg' % (config('countryDirectory'), country))
def get_country_code(country_name): for code, name in COUNTRIES.items(): if name == country_name: return code if country_name == 'Russia': return 'ru' elif country_name == 'US': return 'us' elif country_name == 'Libya': return 'ly' elif country_name == 'Venezuela': return 've' elif country_name == 'Bolivia': return 'bo' elif country_name == 'India': return 'in' elif country_name == 'Iran': return 'ir' elif country_name == 'Korea, South': return 'kr' elif country_name == 'Burma': return 'mm' elif country_name == 'Vietnam': return 'vn' elif country_name == 'Taiwan*': return 'tw' elif country_name == 'Tanzania': return 'tz' elif country_name == 'Congo (Brazzaville)': return 'cd' elif country_name == 'Congo (Kinshasa)': return 'cg' elif country_name == 'Czechia': return 'cz'
def get_country_code(country_name): """Return the Pygal 2-digit country code for the given country.""" for code, name in COUNTRIES.items(): if name == country_name: return code if country_name == 'Bolivia': return 'bo' elif country_name == 'Congo, Dem. Rep.': return 'cd' elif country_name == 'Egypt, Arab Rep.': return 'eg' elif country_name == 'Gambia, The': return 'gm' elif country_name == 'Hong Kong SAR, China': return 'hk' elif country_name == 'Iran, Islamic Rep.': return 'ir' elif country_name == 'Korea, Dem. Rep.': return 'kp' elif country_name == 'Korea, Rep.': return 'kr' elif country_name == 'Slovak Republic': return 'sk' elif country_name == 'Venezuela, RB': return 've' elif country_name == 'Vietnam': return 'vn' elif country_name == 'Yemen, Rep.': return 'ye' # If the country wasn't found, return None. else: return None
def get_country_code(country_name): for k, v in COUNTRIES.items(): if v == country_name: return k return None
def get_country_code(country_name): """Возвращает заданной строны ее Pygal код.""" for code, name in COUNTRIES.items(): if name == country_name: return code # Если страна не найдена, вернуть None. return None
def get_country_code(country_name): '''Return the pygal 2-digit country code for the given country''' for code, name in COUNTRIES.items(): if name == country_name: return code return None
def get_country_code(country_name): """Zwraca stosowany przez Pygal dwuznakowy kod przypisany do danego państwa.""" for code, name in COUNTRIES.items(): if name == country_name: return code #Jeżeli państwo nie zostało znalezione, wartością zwrotną będzie None. return None
def get_country_code(country_name): """ Return 2 letters country code used by Pygal to a given country """ for code, name in COUNTRIES.items(): if name == country_name: return code # if found no country, return None return None
def get_country_code(country_name): # return the pygal 2-digit country code for the given country for code, name in COUNTRIES.items(): if name == country_name: return code # if the country wasnt found, return None return None
def get_country_code(country_code): """Return the Pygal 2-digit for given country code""" for code, name in cn.items(): if name == country_code: return code # If country wasnt not found, return None return None
def get_country_code(country_name): for code, name in COUNTRIES.items(): if name == country_name: return code return None
def get_country_code(country_name): '''Return the Pygal 2-digit country code for the given country.''' names = [] codes = [] indices = [] count = 0 for code, name in COUNTRIES.items(): if name.strip() == country_name.strip(): names.append(name) indices.append(count) codes.append(code) count += 1 for i in indices: if country_name == names[i]: return codes[i] if country_name == 'Arab World': return 'arb' elif country_name == 'Venezuela, RB': return 'ven' elif country_name == 'Yemen, Rep.': return 'yem' elif country_name == 'West Bank and Gaza': return 'pse' elif country_name == 'Bolivia': return 'bol' print('Error - ' + country_name) return None
def get_country_code(country_name): for code, name in COUNTRIES.items(): if name == country_name: return code # If the country wasn't found, return None. return None
def get_country_code(country_name): """""" # dict COUNTRIES contains 2-letter country code (key) # and country name (value) for code, name in COUNTRIES.items(): if name == country_name: return code return None
def get_country_code(country_name): """ Zwraca stosowany przez Pygal dwuznakowy kod państwa przypisany danemu państwu. """ for code, name in COUNTRIES.items(): if name == country_name: return code # Jeżeli państwo nie zostało znalezione, wartością zwrotną będzie None. return None
def get_country_code(country_name): """Return the Pygal 2-digit country code for the given country.""" for code, name in COUNTRIES.items(): if name == country_name.title(): return code elif country_name == 'Antarctica': return 'aq' elif country_name == 'Yemen, Rep.': return 'ye' elif country_name == 'Congo, Dem. Rep.': return 'cd' elif country_name == 'Congo, Rep.': return 'cg' elif country_name == 'Egypt, Arab Rep.': return 'eg' elif country_name == 'Sub-Saharan Africa (all income levels)': return 'eh' elif country_name == 'Gambia, The': return 'gm' elif country_name == 'Hong Kong SAR, China': return 'hk' elif country_name == 'Bolivia': return 'bo' elif country_name == 'Iran, Islamic Rep.': return 'ir' elif country_name == 'Kyrgyz Republic': return 'kg' elif country_name == 'Korea, Dem. Rep.': return 'kp' elif country_name == 'Korea, Rep.': return 'kr' elif country_name == 'Lao PDR': return 'la' elif country_name == 'Libya': return 'ly' elif country_name == 'Moldova': return 'md' elif country_name == 'Macedonia, FYR': return 'mk' elif country_name == 'Macao SAR, China': return 'mo' elif country_name == 'Slovak Republic': return 'sk' elif country_name == 'Tanzania': return 'tz' elif country_name == 'Venezuela, RB': return 've' elif country_name == 'Vietnam': return 'vn' elif country_name == 'Yemen, Rep.': return 'ye' # If the country wasn't found, return None. return None
from pygal.maps.world import COUNTRIES for country_code in sorted(COUNTRIES.keys()): print(country_code, COUNTRIES[country_code])
import json from pygal.maps.world import COUNTRIES # Open pop file filename = 'population_data.json' with open(filename) as f: pop = json.load(f) # Build a dictionary of population data. cc_pop = {} for dict in pop: if dict['Year'] == '2010': country_name = dict['Country Name'] population = int(float(dict['Value'])) cc_pop[country_name] = population # See if the country name for COUNTRIES is in cc_pop dictionary # If not then output the COUNTRIES key/value pair to a new dictonary # That will determine what is missing from the world graph missing_countries = {} for k, v in COUNTRIES.items(): try: cc_pop[v] except KeyError: missing_countries[k] = v # Out put the missing countries from COUNTRIES. These will have to be manually # put into country codes print(sorted(missing_countries.items()))