About
Lookup country code (iso 3166) by IP address.
Install
$ pip install ip2country
Or
$ python setup.py install
How to use
First: Implement IStore Interface
You must implement IStore interface in ip2country/interfaces.py.
There is a sample implementation in example/store. This implementation is stored all records on the system memory.
Second: Store the records
store = Store()
parser = Parser(store)
with open(RECORD_FILE) as fp:
parser.do(fp)
See examples/lookup.py:load for more detail.
Third: Lookup the IPAddress
store = Store()
record = store.lookup(IP_ADDRESS)
if record is None:
print('Record not found')
else:
print('{0} is allocated to {1}'.format(IP_ADDRESS, record.cc))
See examples/lookup.py:main for more detail.
Run the tests
$ tox
License
ip2country is licensed under the MIT LICENSE. See ./LICENSE.rst.
Metadata
Release files for ip2country 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ip2country-0.1.1.tar.gz | 4.1 kB | Details |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ip2country-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
| ip2country-0.1.1-py2-none-any.whl | Python 2 | none | any | Details |
Total release size: 18.2 kB
Release files / ip2country-0.1.1.tar.gz
| Download URL | ip2country-0.1.1.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
26d112dc2f6a9ac834757282bef2674eccc4d552d2a05ffa0f1c7260059bcd3a
|
|
BLAKE2b-256 checksum How to use checksums |
e8051476031288bde6aaeccbbf797b802596801c35762d791a5ded50c6c5fac0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / ip2country-0.1.1-py3-none-any.whl
| Download URL | ip2country-0.1.1-py3-none-any.whl |
|---|---|
| Size | 7.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cf3a383135779155ec2763ef2ce5c18ccda2d0a4d5c410a963475780a98f4fd1
|
|
BLAKE2b-256 checksum How to use checksums |
09b41abf8b76a84563a977e2cec8af328012ffdf5ed74a97cc6b584117f598ee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / ip2country-0.1.1-py2-none-any.whl
| Download URL | ip2country-0.1.1-py2-none-any.whl |
|---|---|
| Size | 7.1 kB |
| Tags | Python 2 |
|
SHA-256 checksum How to use checksums |
798c56c0c8eaf3168c5eb2285994d808fb9d5cb48ba8b4a3d387cd464b7aeff8
|
|
BLAKE2b-256 checksum How to use checksums |
a2e9cf87beec6dc28965218d973c30b721e30d23587f8f15dd5dcc9a6417a736
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |