<commit_before>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-block:: none

     >>> prettyip.pretty_ipset(IPSet([IP('10.0.0.0/8')]))
    '10.0.0.0/8'

Ranges:

.. code-block:: 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-block:: 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('172.16.31.10/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('192.168.3.11/11'), IP('1.64.0.0/10'),
        IP('172.16.17.32/9')])
     >>> prettyip.pretty_ipset(_)
    '1.0.0.0/8 except 1.0.1.0/24, 1.0.9.0/24'

.. _IPy: https://pypi.python.org/pypi/IPy
<commit_msg>try more rst changes to get pypi to render<commit_after>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:

::

     >>> 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('172.16.31.10/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('192.168.3.11/11'), IP('1.64.0.0/10'),
        IP('172.16.17.32/9')])
     >>> prettyip.pretty_ipset(_)
    '1.0.0.0/8 except 1.0.1.0/24, 1.0.9.0/24'

.. _IPy: https://pypi.python.org/pypi/IPy

{'fraction_non_alphanumeric': 0.27445136819290167, 'fraction_numerical': 0.145759956651314, 'mean_word_length': 2.6772908366533863, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 33, 'https://': 10, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 74, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2421400', 'n_tokens_mistral': 1943, 'n_tokens_neox': 1735, 'n_words': 212}