Esempio n. 1
0
def get_country(country):
    try:
        a = list(COUNTRIES.keys())[list(COUNTRIES.values()).index(country)]
    except Exception:
        return None
    else:
        return a
Esempio n. 2
0
def print_all_country_codes(pattern=''):
    if pattern:
        for code, name in COUNTRIES.items():
            if code.startswith(pattern.lower()):
                print(code + ':' + name)
    else:
        for code, name in COUNTRIES.items():
            print(code + ':' + name)
Esempio n. 3
0
def get_country_code(country_name):
    """根据指定的国家,返回Pygal使用的两个字母的国别码"""
    for code, name in COUNTRIES.items():
        if name == country_name:
            return code
    # 没有找到国家
    return None
def get_country_code(country_name):
    '''根据指定的国家,返回pygal使用的两个字母的国别码'''
    for code, name in COUNTRIES.items():
        if name == country_name:
            return code
            #如果没找到指定的国家,就返回none
    return None
Esempio n. 5
0
def get_country_code(country_name):
    # 根据指定国家名称,返回两位国别码
    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 
    #if the country wasnt found, return None 
    return None
Esempio n. 7
0
 def get_country_code(self, country_name):
     """根据国家名字,获取国别码"""
     for code, name in COUNTRIES.items():
         if name == country_name:
             return code
     #如果未找到,返回None
     return None
Esempio n. 8
0
def pega_cod_pais(country_name):
    """Devolve Codigo de DUAS letras de um Pais"""
    for code, name in COUNTRIES.items():
        if name == country_name:
            return code.upper()  #o Upper foi eu quem colocou ^^
    #Se o Pais Não for encontrado, roda as linhas d baixo:
    return "Pais Não Encontrado"
def get_country_code(country_name):
    """"""
    for code, name in COUNTRIES.items():
        if name == country_name:
            return code
        #
    return None
Esempio n. 10
0
def get_country_code(country_name):
    ''' according to the country name, get the counry code '''
    for code, name in COUNTRIES.items():
        if name == country_name:
            return code
    # if can't find the country
    return None
Esempio n. 11
0
def get_country_code(country_name):
    """根据指定的国家,返回Pygal使用的两个字母的国别码"""

    for code, name in COUNTRIES.items():
        if name == country_name:
            return code
        elif country_name == 'East Asia & Pacific (all income levels)':
            return 'al'
        elif country_name == 'East Asia & Pacific (developing only)':
            return 'ad'
        elif country_name == 'Europe & Central Asia (all income levels)':
            return 'el'
        elif country_name == 'Europe & Central Asia (developing only)':
            return 'ed'
        elif country_name == 'Heavily indebted poor countries (HIPC)':
            return 'hp'
        elif country_name == 'Latin America & Caribbean (all income levels)':
            return 'll'
        elif country_name == 'Latin America & Caribbean (developing only)':
            return 'ld'
        elif country_name == 'Least developed countries: UN classification':
            return 'lu'
        elif country_name == 'Middle East & North Africa (all income levels)':
            return 'ml'
        elif country_name == 'Middle East & North Africa (developing only)':
            return 'md'
        elif country_name == 'Sub-Saharan Africa (all income levels)':
            return 'sl'
        elif country_name == 'Sub-Saharan Africa (developing only)':
            return 'sd'
    #如果没有找到指定的国家,就返回None
    return None
Esempio n. 12
0
def get_country_code(country_name):
    """Возвращает для заданной страны ее код Pygal, состоящий из 2 букв."""
    for code, name in COUNTRIES.items():
        if name == country_name:
            return code
    # Если страна не найдена, вернуть None.
    return None
Esempio n. 13
0
def world_map_test():
    map_style = RotateStyle('#44ff77')
    map = World(style=map_style,
                value_formatter=lambda x: '{}'.format(x) + u'国家')
    map.title = 'world map scope'
    country_list = []
    chinese_name = {
        'United States': u'大美利坚',
        'United Kingdom': u'大英帝国',
        'France': u'法兰西',
        'Italy': u'意大利',
        'Japan': u'东瀛',
        'Germany': u'德意志',
        'Canada': u'加拿大'
    }

    detail_dict = {}
    print(type(chinese_name))
    for code, name in COUNTRIES.items():
        if name in ('United States', 'United Kingdom', 'France', 'Italy',
                    'Japan', 'Germany', 'Canada'):
            country_list.append(code)
            detail_dict[code] = chinese_name[name]
            print(code)
        #if name == 'Russian Federation':
        #    unique=code
    for x in detail_dict.items():
        map.add(u'G7国家', )
    #map.add(u'G8国家',country_list+[unique])
    map.render_to_file('/Users/qmp/Desktop/map1.svg')
Esempio n. 14
0
def get_country_code(country_name):
    for code, name in COUNTRIES.items():
        if name == country_name:
            return code

    # 如果没有找到指定国家就返回none
    return None
Esempio n. 15
0
def get_country_code(country_name):
    """根据国家名称找出对应国家代码的函数"""
    for code, name in COUNTRIES.items():  # COUNTRIES的存在格式是字典数据格式
        if name == contry_name:
            return code

    return None  # 注意这个return的位置, 不能是跟if同层级
Esempio n. 16
0
def get_country_code(country_name):
    """ 根据指定国家 返回2个字符的国别码 """
    for code, name in COUNTRIES.items():
        if name == country_name:
            return code
    #  没有找到国别码
    return None
Esempio n. 17
0
def get_country_code(country_name):
    for code, name in COUNTRIES.items():
        # print(code, name)
        if name == country_name:
            return code
        # 如果没有找到指定的国家,就返回 None
    return None
Esempio n. 18
0
def get_country_code(country_name):
    '''根据国家名,返回两个字母的国别码的函数'''
    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
	return None
Esempio n. 20
0
def get_country_code(country_name):
    """Devolve o código de duas letras da Pygal país, dado o seu nome."""
    for code, name in COUNTRIES.items():
        if name == country_name.title():
            return code
        elif country_name.title() == 'Bolivia':
            return 'bo'
        elif country_name.title() == 'Congo, Rep.':
            return 'cd'
        elif country_name.title() == 'Egypt, Arab Rep.':
            return 'eg'
        elif country_name.title() == 'Gambia, The':
            return 'gm'
        elif country_name.title() == 'Iran, Islamic Rep.':
            return 'ir'
        elif country_name.title() == 'Korea, Rep.':
            return 'kp'
        elif country_name.title() == 'Libya':
            return 'ly'
        elif country_name.title() == 'Slovak Republic':
            return 'sk'
        elif country_name.title() == 'Tanzania':
            return 'tz'
        elif country_name.title() == 'Venezuela, RB':
            return 've'
        elif country_name.title() == 'Vietnam':
            return 'vt'
        elif country_name.title() == 'Yemen, Rep.':
            return 'ye'
    # Se o país não for encontrado, devolve None.
    return None
Esempio n. 21
0
def get_country_code(country_name):
    '''根据指定的国家,返回Pygal使用的两个字母的国别码'''
    for code, name in COUNTRIES.items():
        if name == country_name:
            return code
        elif name == 'Egypt, Arab Rep.':
            return 'eg'
        elif name == 'Gambia, The':
            return 'gm'
        elif name == 'Hong Kong SAR, China':
            return 'hk'
        elif name == 'Iran, Islamic Rep.':
            return 'ir'
        elif name == 'Kyrgyz Republic':
            return 'kg'
        elif name == 'Korea, Dem. People’s Rep.':
            return 'kp'
        elif name == 'Korea, Rep.':
            return 'kr'
        elif name == 'Lao PDR':
            return 'la'
        elif name == 'Slovak Republic':
            return 'sk'
        elif name == 'Tanzania':
            return 'tz'
        elif name == 'Vietnam':
            return 'vn'
        elif name == 'Yemen, Rep.':
            return 'ye'
    # 如果没有找到指定的国家,就返回None
    return None
Esempio n. 22
0
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):
    """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
Esempio n. 24
0
def get_country_code(country_name):
    """根据国家名字返回国家的两位编码"""
    for code, name in COUNTRIES.items():
        if name == country_name:
            return code

    return None
Esempio n. 25
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
Esempio n. 26
0
def get_country_code(country_name):
    for code, name in COUNTRIES.items():
        if name == country_name:
            return code

    #若未找到,则返回none
    return None
Esempio n. 27
0
def get_country_code(country_name):
    """根据指定的国家名字寻找编码"""
    for code, name in COUNTRIES.items():
        if name == country_name:
            return code
    #如果没找到就返回None
    return None
Esempio n. 28
0
def get_country_code(counrty_name):
    """According to the designated country, return two-letter country code"""
    for code, name in COUNTRIES.items():
        if name == counrty_name:
            return code
        #if not find designated country, return None
        return None
Esempio n. 29
0
def convert_to_country_code(country):
    """
    Input: a given country (str)
    Output: compare given country to countries in pygal's COUNTRIES dict. Return a 2-digit code from the dict
    if a complete match was found. Else, display partial matches for user to pick the best match out of three,
    and return the code for that partial match. If no complete or partial match was found, return None.
    """

    partial_matches = []
    for code, name in COUNTRIES.items():
        # Return country code if complete match found
        if name.lower() == country.lower():
            return code
        # Store partial match just in case
        else:
            # Return the longest match between the 2 country names
            country_stripped = strip_country(country)
            partial_match = match(name, country_stripped).strip()
            # Collect code, COUNTRIES name, and given country name as a list item
            partial_matches.append([code, name, partial_match])

    # Return country code after asking user to pick from the top 3 matches of the given country (return None if no
    # match was found)
    code = pick_partial_match(country, partial_matches)
    return code
Esempio n. 30
0
def get_country_code(country_name):
    for code, name in COUNTRIES.items():
        if name == country_name:
            return code
        elif country_name == 'Yemen, Rep.':
            return 'ye'
    return None
Esempio n. 31
0
def get_country_code(country_name):
    '''根据指定的国家,返回Pygal使用的两个字母的国别码'''
    for code, name in COUNTRIES.items():
        if name == country_name:
            return code
        '''如果没有找到指定的国家,就返回Nnoe'''
    return None
Esempio n. 32
0
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

    # 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
    if country_name == "Bolivia":
        return "bo"
    if country_name == "Dominica":
        return "do"
    if country_name == "Egypt, Arab Rep.":
        return "eg"
    if country_name == "Gambia, The":
        return "gm"
    if country_name == "Hong Kong SAR, China":
        return "hk"
    if country_name == "Iran, Islamic Rep.":
        return "ir"
    if country_name == "Korea, Dem. Rep.":
        return "kp"
    if country_name == "Korea, Rep.":
        return "kr"
    if country_name == "Kyrgyz Republic":
        return "kg"
    if country_name == "Lao PDR":
        return "la"
    if country_name == "Libya":
        return "ly"
    if country_name == "Macedonia, FYR":
        return "mk"
    if country_name == "Macao SAR, China":
        return "mo"
    if country_name == "Moldova":
        return "md"
    if country_name == "Slovak Republic":
        return "sk"
    if country_name == "Tanzania":
        return "tz"
    if country_name == "Yemen, Rep.":
        return "ye"
    if country_name == "Venezuela, RB":
        return "ve"
    if country_name == "Vietnam":
        return "vn"
    return None
Esempio n. 35
0
from pygal_maps_world.i18n import COUNTRIES

for country_code in sorted(COUNTRIES.keys()):
    print(country_code, COUNTRIES[country_code])