[ .. ]
IPy is a Python module for handling IPv4 and IPv6 Addresses
and Networks in a fashion similar to perl's Net::IP
and friends. The IP class allows a comfortable parsing and
handling for most notations in use for IPv4 and IPv6
Addresses and Networks.
It enables code like this:
>>> ip = IP('127.0.0.0/30')
>>> for x in ip:
... print x
...
127.0.0.0
127.0.0.1
127.0.0.2
127.0.0.3
>>> ip2 = IP('0x7f000000/30')
>>> ip == ip2
1
>>> ip.reverseNames()
['0.0.0.127.in-addr.arpa.', '1.0.0.127.in-addr.arpa.',
'2.0.0.127.in-addr.arpa.', '3.0.0.127.in-addr.arpa.']
>>> ip.reverseName()
'0-3.0.0.127.in-addr.arpa.'
>>> ip.iptype()
'RESERVED'
It can detect about a dozen different ways of expressing IP
addresses and networks, parse them and distinguish between
IPv4 and IPv6 addresses.
>>> IP('10.0.0.0/8').version()
4
>>> IP('::1').version()
6
>>> print IP(0x7f000001)
127.0.0.1
>>> print IP('0x7f000001')
127.0.0.1
>>> print IP('127.0.0.1')
127.0.0.1
>>> print IP('10')
10.0.0.0
>>> print IP('1080:0:0:0:8:800:200C:417A')
1080:0000:0000:0000:0008:0800:200c:417a
>>> print IP('1080::8:800:200C:417A')
1080:0000:0000:0000:0008:0800:200c:417a
>>> print IP('::1')
0000:0000:0000:0000:0000:0000:0000:0001
>>> print IP('::13.1.68.3')
0000:0000:0000:0000:0000:0000:0d01:4403
>>> print IP('127.0.0.0/8')
127.0.0.0/8
>>> print IP('127.0.0.0/255.0.0.0')
127.0.0.0/8
>>> print IP('127.0.0.0-127.255.255.255')
127.0.0.0/8
>>> IP('10.0.0.0/24').strNormal(q)
'10.0.0.0/24'
>>> IP('10.0.0.0/24').strNormal(2)
'10.0.0.0/255.255.255.0'
>>> IP('10.0.0.0/24').strNormal(3)
'10.0.0.0-10.0.0.255'
See the pydoc output for further enlightment.
I consinder it stable enough to be used in production.
IPy is now maintained by the fine people at INL. GFind it's new home at http://software.inl.fr/trac/trac.cgi/wiki/IPy.
76bb49482b8c99a49505331558d0eb71 IPy-0.42.tar.gz
883aca022bfe7a4a5867995bed267072 IPy-0.41.tar.gz
dc48ed67b75e03c9e3e296b95229adf3 IPy-0.4.tar.gz
Snapshots can be found at http://c0re.23.nu/c0de/snap/. If you have a FreeBSD or OpenBSD system, just go to ports/net/py-ipy and type make install.
Hacked by
the teenage mutant ninja hero coders.
Last modified: Sun Oct 29 11:34:57 CET 2006