Package entropy :: Module misc :: Class EntropyGeoIP

Class EntropyGeoIP

source code

Entropy geo-tagging interface containing useful methods to ease metadata management and transformation. It's a wrapper over GeoIP at the moment dev-python/geoip-python required.

Sample code:

>>> geo = EntropyGeoIp("mygeoipdb.dat")
>>> geo.get_geoip_record_from_ip("123.123.123.123")
{ dict() metadata }
Instance Methods
 
__init__(self, geoip_dbfile)
EntropyGeoIP constructor.
source code
string or None
get_geoip_country_name_from_ip(self, ip_address)
Get country name from IP address.
source code
string or None
get_geoip_country_code_from_ip(self, ip_address)
Get country code from IP address.
source code
dict
get_geoip_record_from_ip(self, ip_address)
Get GeoIP record from IP address.
source code
dict
get_geoip_record_from_hostname(self, hostname)
Get GeoIP record from hostname.
source code
Method Details

__init__(self, geoip_dbfile)
(Constructor)

source code 

EntropyGeoIP constructor.

Parameters:
  • geoip_dbfile (string) - valid GeoIP (Maxmind) database file (.dat) path (download from: http://www.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz)

get_geoip_country_name_from_ip(self, ip_address)

source code 

Get country name from IP address.

Parameters:
  • ip_address (string) - ip address string
Returns: string or None
country name or None

get_geoip_country_code_from_ip(self, ip_address)

source code 

Get country code from IP address.

Parameters:
  • ip_address (string) - ip address string
Returns: string or None
country code or None

get_geoip_record_from_ip(self, ip_address)

source code 

Get GeoIP record from IP address.

Parameters:
  • ip_address (string) - ip address string
Returns: dict
GeoIP record data

get_geoip_record_from_hostname(self, hostname)

source code 

Get GeoIP record from hostname.

Parameters:
  • hostname (string) - ip address string
Returns: dict
GeoIP record data