Exemple #1
0
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):
    """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
Exemple #3
0
def get_country_code(country_name):
    """return the pygal 2-digit country code for given country"""
    for code, name in COUNTRIES.items():
        if name == country_name:
            return code
    #if the country wasn't found, return None
    return None
Exemple #4
0
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
Exemple #5
0
def get_country_code(country_name):
    """Returns Pygal code for country consisting from 2 letters"""
    for code, name in COUNTRIES.items():
        if name == country_name:
            return name

    return None
Exemple #6
0
 def get_two_digit_country_code(self, country):
     for code, name in COUNTRIES.items():
         if country == name:
             return code
         elif code in self.missing_countries and country == self.missing_countries[
                 code]:
             return code
     return None
def get_country_code(country_name):
    ''' Returns the two digit country code '''
    for code, name in COUNTRIES.items():
        if name == country_name:
            return code
        # if the code wasn't found return none
    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
    # If the country wasn't found, return None, to preventing
    # it from failing. Most files have incomplete/corrupt data.
    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
Exemple #10
0
def get_country_code(country_name):
    """Returns the code of two letters of the parameter"""
    for code, name in COUNTRIES.items():
        if name == country_name:
            return code

    #If the country was not found
    return None
Exemple #11
0
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):
    """根据指定的国家,返回Pygal使用的两个字母的国别码"""
    for code, name in COUNTRIES.items():
        if name == country_name:
            return code

    #如果没有找到指定的国家,就返回None
    return None
def get_country_code(country_name):
    """Возвращает для заданной страны её код  в pygal (из 2 букв)"""
    for code, name in COUNTRIES.items():
        if name == country_name:
            return code

    # Если страна не найдена, вернуть 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):
    """Возвращает для заданной страны ее код Pygal, состоящий из 2 букв."""
    for code, name in COUNTRIES.items():
        if name == country_name:
            return code

    # Если страна не найдена, вернуть None
    return None
Exemple #16
0
def get_country_code(country_name):
    """根据国家的名称,返回pygal中两个字母的国别码"""
    for code, name in COUNTRIES.items():
        # 判断国名是否相同
        if name == country_name:
            return code
    # 如果没有指定的国家就返回None
    return None
Exemple #17
0
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
Exemple #18
0
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
Exemple #19
0
def bicode(name):
    with open('add_correct_cods.json') as acc:
        correct = json.load(acc)
    for a, b in COUNTRIES.items():
        if b == name:
            return a
    if name in correct:
        return correct[name]
    return None
Exemple #20
0
def country_name_to_code(name):
    try:
        for k, v in COUNTRIES.items():
            if name == v:
                return k
            elif name == 'Iran, Islamic Rep.':
                return 'ir'
    except:
        return None
def get_country_code(country_name):

    #возвращает код Pygal для заданной страны
    for code, name in COUNTRIES.items():
        if name == country_name:
            return code

    #Если старна не найдена вернуть None
    return None
Exemple #22
0
def get_country_code(country_name):
    """Devolve o código de duas letras 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 o None
    return None
Exemple #23
0
def get_country_code(country_name):
    """return pygal 2 digit country code from peripheral lib"""

    for code, name in cnt.items():
        if name == country_name:
            return code

    # if code not found
    return None
Exemple #24
0
def get_country_code(country_name):
    for code, name in COUNTRIES.items():
        if name == country_name:
            return code
    return None

#print(get_country_code('Andorra'))
#print(get_country_code('United Arab Emirates'))
#print(get_country_code('Afghanistan'))
Exemple #25
0
def get_country_code(country_name: str):
    if country_name == 'Taiwan*':
        # country_name = 'Taiwan (Republic of China)'
        country_name = 'Taiwan, Province of China'  # f**k you
    elif country_name == 'Bolivia':
        country_name = 'Bolivia, Plurinational State of'
    elif country_name == 'Brunei':
        country_name = 'Brunei Darussalam'
    elif country_name == 'Burma':
        country_name = 'Myanmar'
    elif country_name == 'Cabo Verde':
        country_name = 'Cape Verde'
    elif country_name == 'Congo (Kinshasa)':
        country_name = 'Congo, the Democratic Republic of the'
    elif country_name == 'Congo (Brazzaville)':
        country_name = 'Congo'
    elif country_name == 'Czechia':
        country_name = 'Czech Republic'
    elif country_name == 'Eswatini':
        country_name = 'Swaziland'
    elif country_name == 'Holy See':
        country_name = 'Holy See (Vatican City State)'
    elif country_name == 'Iran':
        country_name = 'SIran, Islamic Republic of'
    elif country_name == 'Korea, South':
        country_name = 'Korea, Republic of'
    elif country_name == 'Laos':
        country_name = 'Lao People’s Democratic Republic'
    elif country_name == 'Libya':
        country_name = 'Libyan Arab Jamahiriya'
    elif country_name == 'Moldova':
        country_name = 'Moldova, Republic of'
    elif country_name == 'North Macedonia':
        country_name = 'Macedonia, the former Yugoslav Republic of'
    elif country_name == 'Russia':
        country_name = 'Russian Federation'
    elif country_name == 'South Sudan':
        country_name = 'Sudan'
    elif country_name == 'Syria':
        country_name = 'Syrian Arab Republic'
    elif country_name == 'Tanzania':
        country_name = 'Tanzania, United Republic of'
    elif country_name == 'Venezuela':
        country_name = 'Venezuela, Bolivarian Republic of'
    elif country_name == 'Vietnam':
        country_name = 'Viet Nam'
    elif country_name == 'West Bank and Gaza':
        country_name = 'Palestine, State of'
    elif country_name == 'US':
        country_name = 'United States'

    for code, name in COUNTRIES.items():
        if name == country_name:
            return code

    return country_name
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
Exemple #27
0
def world_country_map():
    """绘制世界地图"""
    wm_c = World()
    # wm_c.force_url_protocol = 'http'
    wm_c.title = 'World Map'
    for code, name in COUNTRIES.items():
        wm_c.add(name, code)

    wm_c.add('Yemen', {'ye': 'Yemen'})
    wm_c.render_to_file('world_map.svg')
def get_country_code(country_name):
	'''return pygal's 2 digit code for the given country'''
	for code, name in COUNTRIES.items():
		if name==country_name:
			return code

    # if the country wasnt found, retun None.
	return None
			
		
Exemple #29
0
def get_country_code(country_name):
    ''' Return the Pygal 2-digit country code for the given country '''

    for code, name in COUNTRIES.items():
        # Go through the dictionary looking for the country name
        if name == country_name:
            return code

    # return none if country name not found
    return None
Exemple #30
0
def get_country_code(country_name):
    """根据指定的国家,返回pygal使用的两个字母的国别码"""
    for code, name in COUNTRIES.items():
        if name == country_name:
            return code
    # 如果没有找到指定的国家,就返回None
    return None


# print(get_country_code('Andorra'))
# print(get_country_code('United Arab Emirates'))
def get_country_code(country_name):
  "Возвращает для заланной страны ее код Pygal, состоящий из 2 букв"
  for code, name in COUNTRIES.items():
    if name == country_name:
      return code
  
  # Если страна не найдена, вернуть Ноне
  return None

# print(get_country_code('Kyrgyzstan'))
# print(get_country_code('Afghanistan'))
Exemple #32
0
def get_country_code(country_name):
    '''Return 2-letters country code baed on given country name'''
    for code, name  in COUNTRIES.items():
        if name == country_name:
            return code
    # Return none if country not found
    return None

# print(get_country_code('Andorra'))
# print(get_country_code('United Arab Emirates'))
# print(get_country_code('Afghanistan'))
Exemple #33
0
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
Exemple #34
0
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 country was not found, return nothing
    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'
    return None


#print(get_country_code('Andorra'))
#print(get_country_code('United Arab Emirates'))
def get_country_code(country_name):
    for code, name in COUNTRIES.items():
        if name == country_name:
            return code

    return None
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()))