A Python package for storing, removing and checking IP's efficiently, Use cases: Blacklisting, Whitelisting etc
Project description
Ip-Model
A Data Structure for efficiently storing, removing and checking all Ipv4 addresses in O(1) time.
v1.0.0
supports for all Ipv4 addresses.
Usage
from ip_model.Ipv4 import Ipv4
blacklist = Ipv4()
To add an IP:
# arg: String
blacklist.add("192.0.0.18")
To remove an IP:
# arg: String
blacklist.remove("192.0.0.18")
To check if an IP is present/not:
# arg: String
# returns: bool
blacklist.is_present("192.0.0.18")
Exception Handling
- Throws
TypeError
: passing Invalid Datatype, incorrect number of arguments - Throws
InvalidIpException
: When an invalid Ip is passed
from ip_model.Exceptions import InvalidIpException
try:
blacklist.add("192.455.554.343")
except InvalidIpException:
print("Incorrect Ipv4 Address")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ip_model-1.0.0.tar.gz
(4.0 kB
view hashes)