Informational Badges:
Some Linting Badges (Where I could find them):
If you like this package please leave a github star so I know to continue maintaining it :)
lib_cidr_trie
This package contains a trie of prefixes for fast lookups
Usage
trie = IPv4CIDRTrie()
cidrs = [ip_network(x) for x in ["1.2.0.0/16", "1.2.3.0/24", "1.2.3.4"]]
for cidr in cidrs:
# for mypy
assert isinstance(cidr, IPv4Network)
trie.insert(cidr)
for cidr in cidrs:
assert isinstance(cidr, IPv4Network)
assert cidr in trie
node = trie.get_most_specific_trie_supernet(cidr)
assert node is not None and node.prefix == cidr
invalid_cidrs = [ip_network(x) for x in ["1.0.0.0/8", "255.255.255.255"]]
for invalid_cidr in invalid_cidrs:
# for mypy
assert isinstance(invalid_cidr, IPv4Network)
assert invalid_cidr not in trie
assert trie.get_most_specific_trie_supernet(invalid_cidr) is None
assert IPv4Network("1.2.4.0/24") in trie
assert IPv4Network("1.2.0.255") in trie
assert IPv4Network("1.3.0.0/16") not in trie
Installation
Install python and pip if you have not already. Then run:
pip3 install lib_cidr_trie
This will install the package and all of it's python dependencies.
If you want to install the project for development:
git clone https://github.com/jfuruness/lib_cidr_trie.git
cd lib_cidr_trie
pip3 install -e .[test]
pre-commit install
To test the development package: Testing
Testing
To test the package after installation:
cd lib_cidr_trie
pytest lib_cidr_trie
ruff check lib_cidr_trie
ruff format lib_cidr_trie
mypy lib_cidr_trie
You can run isolated builds across multiple environments with:
cd lib_cidr_trie
tox --skip-missing-interpreters
Development/Contributing
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature - Commit your changes:
git commit -am 'Add some feature' - Push to the branch:
git push origin my-new-feature - Submit a pull request
- Email me at jfuruness@gmail.com because I don't check github messages
History
-
1.2.11 Removed duplicate mac version in github actions
-
1.2.10 Fixed tox.ini to point to pypy3.11
-
1.2.9 Upgrading dependencies and supported Python versions
-
1.2.8 Removed windows classifier from pyproject.toml
-
1.2.7 Updated dependencies and ruff rules
-
1.2.6 Fixed a bug in the pyproject.toml that screwed up non-local installs
-
1.2.5 Updated README
-
1.2.4 Updated docs and test deps
-
1.2.3 Updated package metadata and fixed some formatting for linters
-
1.1.2 Python version updates
-
1.1.1 Dependency updates
-
1.1.0 Removed a few type ignores for mypy, added PrefixType to dunder init
-
1.0.0 Added linters, updated package structure, fixed typing issues
-
0.0.3 Made it easier to subclass CIDRTrie
-
0.0.2 README update
-
0.0.1 First working version
License
BSD License (see license file)
Metadata
Release files for lib-cidr-trie 1.2.11
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| lib_cidr_trie-1.2.11.tar.gz | 10.9 kB | Without provenance | Details for lib_cidr_trie-1.2.11.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lib_cidr_trie-1.2.11-py3-none-any.whl | Python 3 | none | any | Details for lib_cidr_trie-1.2.11-py3-none-any.whl |
Total release size: 18.9 kB
Release files / lib_cidr_trie-1.2.11.tar.gz
| Download URL | lib_cidr_trie-1.2.11.tar.gz |
|---|---|
| Size | 10.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
50f55fdb8d46c39adc251b7c43b280f4a9ec668dccdbe6d6ca3c79f386127621
|
|
BLAKE2b-256 checksum How to use checksums |
079aef898f1575bb6c9f70ad0f5883fcf5ba9370d969bba318a272c280973a8d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Release files / lib_cidr_trie-1.2.11-py3-none-any.whl
| Download URL | lib_cidr_trie-1.2.11-py3-none-any.whl |
|---|---|
| Size | 8.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
db98f2d45dc0ed950e217a3e7b35960e7fc5e97128453f433b9e643e45084819
|
|
BLAKE2b-256 checksum How to use checksums |
940c7837a4c8192804b4902f1400e60b6db2209b920b6d6adcb745e1ad0d9d32
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Security for lib-cidr-trie 1.2.11
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.