How to use the geonamescache.geonamesdata.us_states function in geonamescache

To help you get started, we’ve selected a few geonamescache examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github yaph / geonamescache / geonamescache / __init__.py View on Github external
"""

__title__ = 'geonamescache'
__version__ = '1.2.0'
__author__ = 'Ramiro Gómez'
__license__ = 'MIT'


import os
import json
from . import geonamesdata


class GeonamesCache:

    us_states = geonamesdata.us_states
    continents = None
    countries = None
    cities = None
    cities_items = None
    cities_by_names = {}
    us_counties = None
    datadir = os.path.dirname(os.path.abspath(__file__))

    def get_dataset_by_key(self, dataset, key):
        return dict((d[key], d) for c, d in list(dataset.items()))

    def get_continents(self):
        if self.continents is None:
            self.continents = self._load_data(
                self.continents, 'continents.json')
        return self.continents