geolocip.py 1.68 KB
Newer Older
1 2
# -*- coding: utf-8 -*-

3
# Copyright(C) 2010-2011 Romain Bignon
4
#
5
# This file is part of weboob.
6
#
7
# weboob is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU Lesser General Public License as published by
9 10 11 12
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# weboob is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU Lesser General Public License for more details.
16
#
17
# You should have received a copy of the GNU Lesser General Public License
18
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
19 20


21
from .base import Capability, BaseObject, StringField, FloatField
22 23


24
__all__ = ['IpLocation', 'CapGeolocIp']
25

26

27
class IpLocation(BaseObject):
28 29 30 31 32 33 34 35 36
    """
    Represents the location of an IP address.
    """
    city =      StringField('City')
    region =    StringField('Region')
    zipcode =   StringField('Zip code')
    country =   StringField('Country')
    lt =        FloatField('Latitude')
    lg =        FloatField('Longitude')
37
    osmlink =   StringField('Link to OpenStreetMap location page')
38 39 40 41
    host =      StringField('Hostname')
    tld =       StringField('Top Level Domain')
    isp =       StringField('Internet Service Provider')

42

43
class CapGeolocIp(Capability):
44 45 46
    """
    Access information about IP addresses database.
    """
47

48
    def get_location(self, ipaddr):
49 50 51 52 53 54 55
        """
        Get location of an IP address.

        :param ipaddr: IP address
        :type ipaddr: str
        :rtype: :class:`IpLocation`
        """
56
        raise NotImplementedError()