Skip to main content

aggregate-prefixes

Fast IPv4 and IPv6 prefix aggregator written in pure Python (no dependency required).

Aggregate-prefixes parses a list of unsorted IPv4 or IPv6 prefixes from either a file or SDTIN and returns a sorted list of aggregates to STDOUT. Errors go to STDERR.

Install

From pip

pip install aggregate-prefixes

From poetry

poetry add git+https://github.com/lamehost/aggregate-prefixes.git

From brew

brew install lamehost/aggregate-prefixes/aggregate-prefixes

From source

git clone https://github.com/lamehost/aggregate-prefixes.git
cd aggregate_prefixes
poetry build
pip install dist/aggregate_prefixes-0.7.2-py3-none-any.whl

CLI Syntax for executable

usage: aggregate-prefixes [-h] [--max-length LENGTH] [--strip-host-mask] [--truncate MASK] [--verbose] [--version] [prefixes]

Aggregates IPv4 or IPv6 prefixes from file or STDIN

positional arguments:
  prefixes              Text file of unsorted list of IPv4 or IPv6 prefixes. Use '-' for STDIN.

options:
  -h, --help            show this help message and exit
  --max-length LENGTH, -m LENGTH
                        Discard longer prefixes prior to processing
  --strip-host-mask, -s
                        Do not print netmask if prefix is a host route (/32 IPv4, /128 IPv6)
  --truncate MASK, -t MASK
                        Truncate IP/mask to network/mask
  --verbose, -v         Display verbose information about the optimisations
  --version, -V         show program's version number and exit

Usage as module

$ python
Python 3.9.1+ (default, Feb  5 2021, 13:46:56)
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> from aggregate_prefixes import aggregate_prefixes
>>> list(aggregate_prefixes(['192.0.2.0/32', '192.0.2.1/32', '192.0.2.2/32']))
['192.0.2.0/31', '192.0.2.2/32']
>>>

Python version compatibility

Tested with:

  • Python 3.9
  • Python 3.10
  • Python 3.11
  • Python 3.12

Metadata

Release files for aggregate-prefixes 0.7.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aggregate-prefixes 0.7.2
File Size Uploaded Provenance Actions
aggregate_prefixes-0.7.2.tar.gz 5.3 kB Without provenance Details for aggregate_prefixes-0.7.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for aggregate-prefixes 0.7.2
File Interpreter ABI Platform Actions
aggregate_prefixes-0.7.2-py3-none-any.whl Python 3 none any Details for aggregate_prefixes-0.7.2-py3-none-any.whl

Total release size: 15.0 kB

Release files / aggregate_prefixes-0.7.2.tar.gz

Download URL aggregate_prefixes-0.7.2.tar.gz
Size 5.3 kB
Tags Source
SHA-256 checksum
How to use checksums
6a459faa9cfff5822bf1ed5a7a4bc34818925f25db80f0534c2ca3ae73f64aec
BLAKE2b-256 checksum
How to use checksums
70fc651df135a8f672674d2fcaa2f4355e78594d88e3964f965849d2c32b1b30
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.11.9 Linux/6.7.12-amd64

Release files / aggregate_prefixes-0.7.2-py3-none-any.whl

Download URL aggregate_prefixes-0.7.2-py3-none-any.whl
Size 9.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
020a146a17de31edd26ce69eeebde28a8eb94638dbfee767052d6871544f02a6
BLAKE2b-256 checksum
How to use checksums
ea0e1979fcd5a5a500b02240a0869df943cb4a70d5af820f6e6c667aa5f5d5d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.11.9 Linux/6.7.12-amd64

Security for aggregate-prefixes 0.7.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page