[entropy.misc] drop EntropyGeoIP, no longer used

This commit is contained in:
Fabio Erculiani
2012-09-15 12:50:53 +02:00
parent e04138541b
commit 58f1682c41

View File

@@ -896,102 +896,6 @@ class EmailSender:
composed = outer.as_string()
return self.default_sender(sender_email, destination_emails, composed)
class EntropyGeoIP:
"""
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 }
"""
def __init__(self, geoip_dbfile):
"""
EntropyGeoIP constructor.
@param geoip_dbfile: valid GeoIP (Maxmind) database file (.dat) path
(download from:
http://www.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz)
@type geoip_dbfile: string
"""
import GeoIP
self.__geoip = GeoIP
# http://www.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
if not (os.path.isfile(geoip_dbfile) and \
os.access(geoip_dbfile, os.R_OK)):
raise AttributeError(
"expecting a valid filepath for geoip_dbfile, got: %s" % (
repr(geoip_dbfile),
)
)
self.__geoip_dbfile = geoip_dbfile
def __get_geo_ip_generic(self):
""" Private method """
return self.__geoip.new(self.__geoip.GEOIP_MEMORY_CACHE)
def __get_geo_ip_open(self):
""" Private method """
return self.__geoip.open(self.__geoip_dbfile,
self.__geoip.GEOIP_STANDARD)
def get_geoip_country_name_from_ip(self, ip_address):
"""
Get country name from IP address.
@param ip_address: ip address string
@type ip_address: string
@return: country name or None
@rtype: string or None
"""
gi_a = self.__get_geo_ip_generic()
return gi_a.country_name_by_addr(ip_address)
def get_geoip_country_code_from_ip(self, ip_address):
"""
Get country code from IP address.
@param ip_address: ip address string
@type ip_address: string
@return: country code or None
@rtype: string or None
"""
gi_a = self.__get_geo_ip_generic()
return gi_a.country_code_by_addr(ip_address)
def get_geoip_record_from_ip(self, ip_address):
"""
Get GeoIP record from IP address.
@param ip_address: ip address string
@type ip_address: string
@return: GeoIP record data
@rtype: dict
"""
go_a = self.__get_geo_ip_open()
return go_a.record_by_addr(ip_address)
def get_geoip_record_from_hostname(self, hostname):
"""
Get GeoIP record from hostname.
@param hostname: ip address string
@type hostname: string
@return: GeoIP record data
@rtype: dict
"""
go_a = self.__get_geo_ip_open()
return go_a.record_by_name(hostname)
class RSS: