How to use the geoip2.records.Country function in geoip2

To help you get started, we’ve selected a few geoip2 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 maxmind / GeoIP2-python / geoip2 / models.py View on Github external
def __init__(self, raw_response, locales=None):
        if locales is None:
            locales = ['en']
        self._locales = locales
        self.continent = \
            geoip2.records.Continent(locales,
                                     **raw_response.get('continent', {}))
        self.country = \
            geoip2.records.Country(locales,
                                   **raw_response.get('country', {}))
        self.registered_country = \
            geoip2.records.Country(locales,
                                   **raw_response.get('registered_country',
                                                      {}))
        self.represented_country \
            = geoip2.records.RepresentedCountry(locales,
                                                **raw_response.get(
                                                    'represented_country', {}))

        self.maxmind = \
            geoip2.records.MaxMind(**raw_response.get('maxmind', {}))

        self.traits = geoip2.records.Traits(**raw_response.get('traits', {}))
        self.raw = raw_response
github maxmind / GeoIP2-python / geoip2 / records.py View on Github external
def __init__(self,
                 locales=None,
                 confidence=None,
                 geoname_id=None,
                 is_in_european_union=False,
                 iso_code=None,
                 names=None,
                 **_):
        self.confidence = confidence
        self.geoname_id = geoname_id
        self.is_in_european_union = is_in_european_union
        self.iso_code = iso_code
        super(Country, self).__init__(locales, names)
github maxmind / GeoIP2-python / geoip2 / records.py View on Github external
def __init__(self,
                 locales=None,
                 confidence=None,
                 geoname_id=None,
                 is_in_european_union=False,
                 iso_code=None,
                 names=None,
                 **_):
        self.confidence = confidence
        self.geoname_id = geoname_id
        self.is_in_european_union = is_in_european_union
        self.iso_code = iso_code
        super(Country, self).__init__(locales, names)


class RepresentedCountry(Country):
    """Contains data for the represented country associated with an IP address.

    This class contains the country-level data associated with an IP address
    for the IP's represented country. The represented country is the country
    represented by something like a military base.

    Attributes:


    .. attribute:: confidence

      A value from 0-100 indicating MaxMind's confidence that
      the country is correct. This attribute is only available from the
      Insights end point and the GeoIP2 Enterprise database.

      :type: int
github m-lab / mlab-ns / server / mlabns / third_party / geoip2 / geoip2 / models.py View on Github external
def __init__(self, raw_response, locales=None):
        if locales is None:
            locales = ['en']
        self._locales = locales
        self.continent = \
            geoip2.records.Continent(locales,
                                     **raw_response.get('continent', {}))
        self.country = \
            geoip2.records.Country(locales,
                                   **raw_response.get('country', {}))
        self.registered_country = \
            geoip2.records.Country(locales,
                                   **raw_response.get('registered_country',
                                                      {}))
        self.represented_country \
            = geoip2.records.RepresentedCountry(locales,
                                                **raw_response.get(
                                                    'represented_country', {}))

        self.maxmind = \
            geoip2.records.MaxMind(**raw_response.get('maxmind', {}))

        self.traits = geoip2.records.Traits(**raw_response.get('traits', {}))
        self.raw = raw_response
github m-lab / mlab-ns / server / mlabns / third_party / geoip2 / geoip2 / models.py View on Github external
def __init__(self, raw_response, locales=None):
        if locales is None:
            locales = ['en']
        self._locales = locales
        self.continent = \
            geoip2.records.Continent(locales,
                                     **raw_response.get('continent', {}))
        self.country = \
            geoip2.records.Country(locales,
                                   **raw_response.get('country', {}))
        self.registered_country = \
            geoip2.records.Country(locales,
                                   **raw_response.get('registered_country',
                                                      {}))
        self.represented_country \
            = geoip2.records.RepresentedCountry(locales,
                                                **raw_response.get(
                                                    'represented_country', {}))

        self.maxmind = \
            geoip2.records.MaxMind(**raw_response.get('maxmind', {}))

        self.traits = geoip2.records.Traits(**raw_response.get('traits', {}))
        self.raw = raw_response
github maxmind / GeoIP2-python / geoip2 / models.py View on Github external
def __init__(self, raw_response, locales=None):
        if locales is None:
            locales = ['en']
        self._locales = locales
        self.continent = \
            geoip2.records.Continent(locales,
                                     **raw_response.get('continent', {}))
        self.country = \
            geoip2.records.Country(locales,
                                   **raw_response.get('country', {}))
        self.registered_country = \
            geoip2.records.Country(locales,
                                   **raw_response.get('registered_country',
                                                      {}))
        self.represented_country \
            = geoip2.records.RepresentedCountry(locales,
                                                **raw_response.get(
                                                    'represented_country', {}))

        self.maxmind = \
            geoip2.records.MaxMind(**raw_response.get('maxmind', {}))

        self.traits = geoip2.records.Traits(**raw_response.get('traits', {}))
        self.raw = raw_response