コード例 #1
0
def capitales_etudiee_oecd():
    '''
    Enable to retrieve OECD countries capitals through CountryInfo() method.
    This is useful for OpenWeatherMap informations extracting.

    ==> Countries capitals are return in a dictionnary as follows:
    {
    ...
    'SRI LANKA': 'Colombo',
    'SUDAN': 'Khartoum', etc
    ...
    }

    '''
    with open('app/static/json/city.list.json') as f:
        data = json.load(f)
    capitales_oecd = {}
    nom_pays_ocde_majuscules = []
    nom_pays_open_weather_majuscules = []
    pays_communs_pour_projet = []

    for pays in nom_des_pays:
        nom_pays_ocde_majuscules.append(pays.upper())
    infos_pays = CountryInfo()
    infos_pays = infos_pays.all()
    infos_pays = dict(infos_pays)

    for pays in infos_pays.keys():
        nom_pays_open_weather_majuscules.append(pays.upper())

    ### Creation of a set in order to find similar cities within lists
    pays_ocde = set(nom_pays_ocde_majuscules)
    pays_open_weather = set(nom_pays_open_weather_majuscules)
    pays_communs_pour_projet = pays_ocde.intersection(pays_open_weather)

    ### Converting set in list
    pays_communs_pour_projet = list(pays_communs_pour_projet)
    pays_communs_pour_projet.sort(reverse=False)

    for pays in pays_communs_pour_projet:
        country = CountryInfo(pays)
        # capitale = country.capital().upper()
        capitale = country.capital()
        capitales_oecd[pays] = capitale

    return capitales_oecd
コード例 #2
0
 def handle(self, *args, **options):
     """
     Handle call
     """
     datafile = os.path.join(os.path.dirname(__file__), '..', '..',
                             'data.py')
     currency_countries = {}
     from countryinfo import CountryInfo
     ci = CountryInfo()
     for value in ci.all().values():
         for currency in value.get('currencies', []):
             if currency in currency_countries:
                 currency_countries[currency].append(value['ISO']['alpha2'])
             else:
                 currency_countries[currency] = [
                     value['ISO']['alpha2'],
                 ]
     with open(datafile, "w") as fp:
         fp.write(f"CURRENCY_COUNTRIES = "
                  f"{json.dumps(currency_countries, indent=2)}\n")
コード例 #3
0
def get_all_countries_by_country():
    country = CountryInfo()
    return country.all().keys()
コード例 #4
0
import readerJHU
import numpy as np

from countryinfo import CountryInfo

CD = readerJHU.CovidData()
CD.loadData()

country = CountryInfo()
allCountries = country.all()

countriesOnRecord = [
    "Argentina", "Brazil", "Czechia", "China", "France", "Germany", "Iran",
    "Italy", "Pakistan", "Spain", "Sweden", "Switzerland", "Turkey",
    "United Kingdom", "US"
]

countriesOnRecordString = """
countryParameters["Argentina"] = {"All" : createDictionary(17.605, 30, 4, "ar")};
countryParameters["Brazil"] = {"All" : createDictionary(19.15, 28, 5, "br")};
countryParameters["Czechia"] = {"All" : createDictionary(16.18, 29, 3.7, "cz")};
countryParameters["China"] = {"Beijing" : createDictionary(16.885, 0, 3, "cn"),"Hubei" : createDictionary(17.884, 0, 3, "cn")};
countryParameters["France"] = {"All" : createDictionary(18.018, 20, 5, "fr")};
countryParameters["Germany"] = {"All" : createDictionary(18.23, 20, 4.6, "de")};
countryParameters["Iran"] = {"All" : createDictionary(18.21, 18, 5, "ir")};
countryParameters["Italy"] = {"All" : createDictionary(17.917, 0, 4, "it")};
countryParameters["Pakistan"] = {"All" : createDictionary(19.098, 35, 4, "pk")};
countryParameters["Spain"] = {"All" : createDictionary(17.664, 20, 5, "es")};
countryParameters["Sweden"] = {"All" : createDictionary(16.130, 30, 5, "se")};
countryParameters["Switzerland"] = {"All" : createDictionary(15.963, 30, 5, "ch")};
countryParameters["Turkey"] = {"All" : createDictionary(18.2076, 30, 5, "tr")};