Commit f3b8087f by William Tisäter

Add alias methods for ISP and ASN lookup

parent 1583506f
......@@ -95,7 +95,7 @@ Create your GeoIP instance with appropriate access flag. `STANDARD` reads data f
```python
>>> gi = pygeoip.GeoIP('/path/to/GeoIPISP.dat')
>>> gi.org_by_name('cnn.com')
>>> gi.isp_by_name('cnn.com')
'Turner Broadcasting System'
```
......@@ -103,7 +103,7 @@ Create your GeoIP instance with appropriate access flag. `STANDARD` reads data f
```python
>>> gi = pygeoip.GeoIP('/path/to/GeoIPASNum.dat')
>>> gi.org_by_name('cnn.com')
>>> gi.asn_by_name('cnn.com')
'AS5662 Turner Broadcasting'
```
......
......@@ -574,6 +574,11 @@ class GeoIP(object):
addr = self._gethostbyname(hostname)
return self.org_by_addr(addr)
isp_by_addr = org_by_addr
isp_by_name = org_by_name
asn_by_addr = org_by_addr
asn_by_name = org_by_name
def record_by_addr(self, addr):
"""
Look up the record for a given IP address.
......
......@@ -19,15 +19,15 @@ class TestGeoIPASNumFunctions(unittest.TestCase):
self.gia = pygeoip.GeoIP(ASNUM_DB_PATH)
def testOrgByAddr(self):
gb_as = self.gia.org_by_addr(self.gb_ip)
us_as = self.gia.org_by_addr(self.us_ip)
gb_as = self.gia.asn_by_addr(self.gb_ip)
us_as = self.gia.asn_by_addr(self.us_ip)
self.assertEqual(gb_as, self.gb_as)
self.assertEqual(us_as, self.us_as)
def testOrgByName(self):
gb_as = self.gia.org_by_name(self.gb_hostname)
us_as = self.gia.org_by_name(self.us_hostname)
gb_as = self.gia.asn_by_name(self.gb_hostname)
us_as = self.gia.asn_by_name(self.us_hostname)
self.assertEqual(gb_as, self.gb_as)
self.assertEqual(us_as, self.us_as)
......
......@@ -18,15 +18,15 @@ class TestGeOIPISPFunctions(unittest.TestCase):
self.gi = pygeoip.GeoIP(ISP_DB_PATH)
def testISPByAddr(self):
se_isp = self.gi.org_by_addr(self.se_ip)
us_isp = self.gi.org_by_addr(self.us_ip)
se_isp = self.gi.isp_by_addr(self.se_ip)
us_isp = self.gi.isp_by_addr(self.us_ip)
self.assertEqual(se_isp, self.se_isp)
self.assertEqual(us_isp, self.us_isp)
def testISPByName(self):
se_isp = self.gi.org_by_name(self.se_hostname)
us_isp = self.gi.org_by_name(self.us_hostname)
se_isp = self.gi.isp_by_name(self.se_hostname)
us_isp = self.gi.isp_by_name(self.us_hostname)
self.assertEqual(se_isp, self.se_isp)
self.assertEqual(us_isp, self.us_isp)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment