Pretty-print IPy’s IPSets in a human-readable fashion.
Compatibility
Everywhere IPy runs, so does this – CPython-2.6 through 3.4.
Usage
Explicitly:
from IPy import IPSet, IP
import prettyip
my_ipset = IPSet([IP('10.0.0.0/8')]) - IPSet([IP('10.0.1.2')])
print prettyip.pretty_ipset(my_ipset)
Or, monkey-patch IPy:
import prettyip
prettyip.patch_ipy()
my_ipset = IPSet([IP('10.0.0.0/8')]) - IPSet([IP('10.0.1.2')])
print my_ipset
Results
Simple IPs:
>>> prettyip.pretty_ipset(IPSet([IP('10.0.0.0/8')]))
'10.0.0.0/8'
Ranges:
>>> IPSet([IP('10.120.13.11'), IP('10.120.13.12/30'), IP('10.120.13.16')])
IPSet([IP('10.120.13.11'), IP('10.120.13.12/30'), IP('10.120.13.16')])
>>> prettyip.pretty_ipset(_)
'10.120.13.1{1-6}'
Big netblocks with smaller pieces missing:
>>> IPSet([IP('1.0.0.0/8')]) - IPSet([IP('1.0.1.0/24')]) - IPSet([IP('1.0.9.0/24')])
IPSet([IP('1.0.0.0/24'), IP('1.0.2.0/23'), IP('1.0.4.0/22'),
IP('1.0.8.0/24'), IP('1.0.10.0/23'), IP('1.0.12.0/22'), IP('1.0.16.0/20'),
IP('1.0.32.0/19'), IP('1.0.64.0/18'), IP('1.0.128.0/17'),
IP('1.1.0.0/16'), IP('1.2.0.0/15'), IP('1.4.0.0/14'), IP('1.8.0.0/13'),
IP('1.16.0.0/12'), IP('1.32.0.0/11'), IP('1.64.0.0/10'),
IP('1.128.0.0/9')])
>>> prettyip.pretty_ipset(_)
'1.0.0.0/8 except 1.0.1.0/24, 1.0.9.0/24'
Release files for prettyip 1.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| prettyip-1.1.4.tar.gz | 14.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| prettyip-1.1.4-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 21.6 kB
Release files / prettyip-1.1.4.tar.gz
| Download URL | prettyip-1.1.4.tar.gz |
|---|---|
| Size | 14.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6c6ff54f387de3fbf6acbf1d8cef28369bf19019012ef0de5466627c2ed3b913
|
|
BLAKE2b-256 checksum How to use checksums |
5f6ee995158243b22ed39cdcddaac26073815373698b9944aeb60eb0b379ff5f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / prettyip-1.1.4-py2.py3-none-any.whl
| Download URL | prettyip-1.1.4-py2.py3-none-any.whl |
|---|---|
| Size | 6.7 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
54a3a323e1922fef9f48ad3f9e2f61f705ae14295ffa7cb5fb5c0186a688e66b
|
|
BLAKE2b-256 checksum How to use checksums |
a971cb1b615ddfb12051a1a1a2593cc78f925db1268cca4f8e27b5b75c607958
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |