Pretty-print IPy's IPSets
Project description
prettyip
========
Pretty-print IPy_'s IPSets in a human-readable fashion.
.. image:: https://coveralls.io/repos/djmitche/prettyip/badge.svg?branch=master
:target: https://coveralls.io/r/djmitche/prettyip?branch=master
.. image:: https://travis-ci.org/djmitche/prettyip.svg?branch=master
:target: https://travis-ci.org/djmitche/prettyip
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:
.. code-sample:: none
>>> prettyip.pretty_ipset(IPSet([IP('10.0.0.0/8')]))
'10.0.0.0/8'
Ranges:
.. code-sample:: none
>>> 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:
.. code-sample:: none
>>> 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'
.. _IPy: https://pypi-hypernode.com/pypi/IPy
========
Pretty-print IPy_'s IPSets in a human-readable fashion.
.. image:: https://coveralls.io/repos/djmitche/prettyip/badge.svg?branch=master
:target: https://coveralls.io/r/djmitche/prettyip?branch=master
.. image:: https://travis-ci.org/djmitche/prettyip.svg?branch=master
:target: https://travis-ci.org/djmitche/prettyip
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:
.. code-sample:: none
>>> prettyip.pretty_ipset(IPSet([IP('10.0.0.0/8')]))
'10.0.0.0/8'
Ranges:
.. code-sample:: none
>>> 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:
.. code-sample:: none
>>> 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'
.. _IPy: https://pypi-hypernode.com/pypi/IPy
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
prettyip-1.1.2.tar.gz
(14.9 kB
view details)
Built Distribution
File details
Details for the file prettyip-1.1.2.tar.gz
.
File metadata
- Download URL: prettyip-1.1.2.tar.gz
- Upload date:
- Size: 14.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 809183e48bcac82777fe773c33aaddfdba6b181af9a01de108318c24cd16814e |
|
MD5 | 0ee45298dafa09c15fc29247b8e9a609 |
|
BLAKE2b-256 | c5bb5af3b495da9373b40c294e406a9702e99288580294c71985246dc7b403e2 |
File details
Details for the file prettyip-1.1.2-py2.py3-none-any.whl
.
File metadata
- Download URL: prettyip-1.1.2-py2.py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d848618c9854f4543dbd890cf288bd732a322cb5f568f9509ace6ea17f878b3 |
|
MD5 | b6c1c9c48f69dc9564cd81930b39155d |
|
BLAKE2b-256 | 27546d6b34d3dda0328ed2179c5fac312e2d444828f707c53e6d4812b897e678 |