예제 #1
0
def get_country(country):
    try:
        a = list(COUNTRIES.keys())[list(COUNTRIES.values()).index(country)]
    except Exception:
        return None
    else:
        return a
예제 #2
0
class World(BaseMap):
    """Worldmap graph"""
    x_labels = list(COUNTRIES.keys())
    area_names = COUNTRIES
    area_prefix = ''
    svg_map = WORLD_MAP
    kind = 'country'

    @cached_property
    def countries(self):
        return [
            val[0] for serie in self.all_series for val in serie.values
            if val[0] is not None
        ]

    @cached_property
    def _values(self):
        """Getter for series values (flattened)"""
        return [
            val[1] for serie in self.series for val in serie.values
            if val[1] is not None
        ]
예제 #3
0
"""Countries.py"""

from pygal_maps_world.i18n import COUNTRIES

for country_code in sorted(COUNTRIES.keys()):
    print(country_code, COUNTRIES[country_code])
예제 #4
0
from pygal_maps_world.i18n import COUNTRIES

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


예제 #5
0
파일: t1.py 프로젝트: maxfactory/pythontest
from pygal_maps_world.i18n import COUNTRIES
# print(COUNTRIES)
for k in COUNTRIES.keys():
    print(k + ":" + COUNTRIES[k])
예제 #6
0
def print_code_name():
    #pygal绘图时使用的是两个字母的国别码,而文件里使用的是三个
    #字母,因此需要使用i18n模块进行转换。先打印国别码和国家名:
    for country_code in sorted(COUNTRIES.keys()):
        print(country_code, COUNTRIES[country_code])
예제 #7
0
import pygal
from pygal_maps_world.i18n import COUNTRIES
# from pygal.maps.world import COUNTRIES
# from pygal_maps_world import i18n

for country_code in COUNTRIES.keys():
    print(country_code, COUNTRIES[country_code])
예제 #8
0
import pygal
from pygal_maps_world.i18n import COUNTRIES

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


def get_code(country_name):
    for code, name in COUNTRIES.items():
        if name == country_name:
            return code
    return None
예제 #9
0
from pygal_maps_world.i18n import COUNTRIES
import json

# 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 

# filename = 'population_data.json'

# with open(filename) as f:
#     pop_data = json.load(f)

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

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

for items