No project description provided
Project description
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
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
Built Distribution
File details
Details for the file aggregate_prefixes-0.7.2.tar.gz
.
File metadata
- Download URL: aggregate_prefixes-0.7.2.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.9 Linux/6.7.12-amd64
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a459faa9cfff5822bf1ed5a7a4bc34818925f25db80f0534c2ca3ae73f64aec |
|
MD5 | 7271290f1e58ffeda7d6f2a1fee16c7f |
|
BLAKE2b-256 | 70fc651df135a8f672674d2fcaa2f4355e78594d88e3964f965849d2c32b1b30 |
File details
Details for the file aggregate_prefixes-0.7.2-py3-none-any.whl
.
File metadata
- Download URL: aggregate_prefixes-0.7.2-py3-none-any.whl
- Upload date:
- Size: 9.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.9 Linux/6.7.12-amd64
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 020a146a17de31edd26ce69eeebde28a8eb94638dbfee767052d6871544f02a6 |
|
MD5 | f4ffefbbfd522d1751da53ea759b53d3 |
|
BLAKE2b-256 | ea0e1979fcd5a5a500b02240a0869df943cb4a70d5af820f6e6c667aa5f5d5d7 |