Exscript.util.ip module

Wrapper around the ipv4 and ipv6 modules to handle both, ipv4 and ipv6.

Exscript.util.ip.clean_ip(ip)[source]

Cleans the ip address up, useful for removing leading zeros, e.g.:

192.168.010.001 -> 192.168.10.1
1234:0000:0000:0000:0000:0000:0000:000A -> 1234::a
Parameters:ip (string) – An IP address.
Return type:string
Returns:The cleaned up IP.
Exscript.util.ip.is_ip(string)[source]

Returns True if the given string is an IPv4 or IPv6 address, False otherwise.

Parameters:string (string) – Any string.
Return type:bool
Returns:True if the string is an IP address, False otherwise.
Exscript.util.ip.normalize_ip(ip)[source]

Transform the address into a fixed-length form, such as:

192.168.0.1 -> 192.168.000.001 1234::A -> 1234:0000:0000:0000:0000:0000:0000:000a
Parameters:ip (string) – An IP address.
Return type:string
Returns:The normalized IP.