How to use the geoip2.mixins.SimpleEquality 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
These classes provide models for the data returned by the GeoIP2
web service and databases.

The only difference between the City and Insights model classes is which
fields in each record may be populated. See
http://dev.maxmind.com/geoip/geoip2/web-services for more details.

"""
# pylint: disable=too-many-instance-attributes,too-few-public-methods
from abc import ABCMeta

import geoip2.records
from geoip2.mixins import SimpleEquality


class Country(SimpleEquality):
    """Model for the GeoIP2 Precision: Country and the GeoIP2 Country database.

    This class provides the following attributes:

    .. attribute:: continent

      Continent object for the requested IP address.

      :type: :py:class:`geoip2.records.Continent`

    .. attribute:: country

      Country object for the requested IP address. This record represents the
      country where MaxMind believes the IP is located.

      :type: :py:class:`geoip2.records.Country`
github maxmind / GeoIP2-python / geoip2 / records.py View on Github external
Records
=======

"""
# pylint:disable=too-many-arguments,too-many-instance-attributes,too-many-locals

import ipaddress

# pylint:disable=R0903
from abc import ABCMeta

from geoip2.compat import compat_ip_network
from geoip2.mixins import SimpleEquality


class Record(SimpleEquality):
    """All records are subclasses of the abstract class ``Record``."""

    __metaclass__ = ABCMeta

    def __repr__(self):
        args = ', '.join('%s=%r' % x for x in self.__dict__.items())
        return '{module}.{class_name}({data})'.format(
            module=self.__module__,
            class_name=self.__class__.__name__,
            data=args)


class PlaceRecord(Record):
    """All records with :py:attr:`names` subclass :py:class:`PlaceRecord`."""

    __metaclass__ = ABCMeta
github m-lab / mlab-ns / server / mlabns / third_party / geoip2 / geoip2 / models.py View on Github external
Object (tuple) representing the subdivisions of the country to which
      the location of the requested IP address belongs.

      :type: :py:class:`geoip2.records.Subdivisions`

    .. attribute:: traits

      Object with the traits of the requested IP address.

      :type: :py:class:`geoip2.records.Traits`

    """


class SimpleModel(SimpleEquality):
    """Provides basic methods for non-location models"""

    __metaclass__ = ABCMeta

    def __repr__(self):
        # pylint: disable=no-member
        return '{module}.{class_name}({data})'.format(
            module=self.__module__,
            class_name=self.__class__.__name__,
            data=str(self.raw))


class AnonymousIP(SimpleModel):
    """Model class for the GeoIP2 Anonymous IP.

    This class provides the following attribute:
github m-lab / mlab-ns / server / mlabns / third_party / geoip2 / geoip2 / records.py View on Github external
"""

Records
=======

"""

# pylint:disable=R0903
from abc import ABCMeta

from geoip2.mixins import SimpleEquality


class Record(SimpleEquality):
    """All records are subclasses of the abstract class ``Record``."""

    __metaclass__ = ABCMeta

    _valid_attributes = set()

    def __init__(self, **kwargs):
        valid_args = dict((k, kwargs.get(k)) for k in self._valid_attributes)
        self.__dict__.update(valid_args)

    def __setattr__(self, name, value):
        raise AttributeError("can't set attribute")

    def __repr__(self):
        args = ', '.join('%s=%r' % x for x in self.__dict__.items())
        return '{module}.{class_name}({data})'.format(
github maxmind / GeoIP2-python / geoip2 / models.py View on Github external
Object (tuple) representing the subdivisions of the country to which
      the location of the requested IP address belongs.

      :type: :py:class:`geoip2.records.Subdivisions`

    .. attribute:: traits

      Object with the traits of the requested IP address.

      :type: :py:class:`geoip2.records.Traits`

    """


class SimpleModel(SimpleEquality):
    """Provides basic methods for non-location models"""

    __metaclass__ = ABCMeta

    def __repr__(self):
        # pylint: disable=no-member
        return '{module}.{class_name}({data})'.format(
            module=self.__module__,
            class_name=self.__class__.__name__,
            data=str(self.raw))


class AnonymousIP(SimpleModel):
    """Model class for the GeoIP2 Anonymous IP.

    This class provides the following attribute:
github m-lab / mlab-ns / server / mlabns / third_party / geoip2 / geoip2 / models.py View on Github external
These classes provide models for the data returned by the GeoIP2
web service and databases.

The only difference between the City and Insights model classes is which
fields in each record may be populated. See
http://dev.maxmind.com/geoip/geoip2/web-services for more details.

"""
# pylint: disable=too-many-instance-attributes,too-few-public-methods
from abc import ABCMeta

import geoip2.records
from geoip2.mixins import SimpleEquality


class Country(SimpleEquality):
    """Model for the GeoIP2 Precision: Country and the GeoIP2 Country database.

    This class provides the following attributes:

    .. attribute:: continent

      Continent object for the requested IP address.

      :type: :py:class:`geoip2.records.Continent`

    .. attribute:: country

      Country object for the requested IP address. This record represents the
      country where MaxMind believes the IP is located.

      :type: :py:class:`geoip2.records.Country`