Name | lib-cidr-trie JSON |
Version |
1.2.8
JSON |
| download |
home_page | None |
Summary | Contains a trie of prefixes for fast lookups |
upload_time | 2024-11-23 11:31:42 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.10 |
license | Copyright 2020 Justin Furuness Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
keywords |
furuness
prefix
cidr
inet
trie
cidr-trie
roas
roas-trie
roas
roas-trie
bgp
hijack
roa
rov
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
Informational Badges:
[![PyPI version](https://badge.fury.io/py/lib_cidr_trie.svg)](https://badge.fury.io/py/lib_cidr_trie)
![PyPy](https://img.shields.io/badge/PyPy-7.3.17-blue)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/lib_cidr_trie)](https://pypi.org/project/lib_cidr_trie/)
![Tests](https://github.com/jfuruness/lib_cidr_trie/actions/workflows/tests.yml/badge.svg)
![Linux](https://img.shields.io/badge/os-Linux-blue.svg)
![macOS Intel](https://img.shields.io/badge/os-macOS_Intel-lightgrey.svg)
![macOS ARM](https://img.shields.io/badge/os-macOS_ARM-lightgrey.svg)
Some Linting Badges (Where I could find them):
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Checked with mypy](https://img.shields.io/badge/mypy-checked-2A6DBA.svg)](http://mypy-lang.org/)
[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)
[![Pylint](https://img.shields.io/badge/linting-pylint-yellowgreen)](https://github.com/pylint-dev/pylint/tree/main)
[![try/except style: tryceratops](https://img.shields.io/badge/try%2Fexcept%20style-tryceratops%20%F0%9F%A6%96%E2%9C%A8-black)](https://github.com/guilatrova/tryceratops)
# 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](#usage)
* [Installation](#installation)
* [Testing](#testing)
* [Development/Contributing](#developmentcontributing)
* [History](#history)
* [Licence](#license)
## Usage
* [lib\_cidr\_trie](#lib_cidr_trie)
```python
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
* [lib\_cidr\_trie](#lib_cidr_trie)
Install python and pip if you have not already. Then run:
```bash
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:
```bash
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)
## Testing
* [lib\_cidr_trie](#lib_cidr_trie)
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
* [lib\_cidr\_trie](#lib_cidr_trie)
1. Fork it!
2. Create your feature branch: `git checkout -b my-new-feature`
3. Commit your changes: `git commit -am 'Add some feature'`
4. Push to the branch: `git push origin my-new-feature`
5. Submit a pull request
6. Email me at jfuruness@gmail.com because I don't check github messages
## History
* [lib\_cidr\_trie](#lib_cidr_trie)
* 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
* [lib\_cidr\_trie](#lib_cidr_trie)
BSD License (see license file)
Raw data
{
"_id": null,
"home_page": null,
"name": "lib-cidr-trie",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "Furuness, prefix, cidr, inet, trie, cidr-trie, roas, roas-trie, ROAs, ROAs-trie, BGP, Hijack, ROA, ROV",
"author": null,
"author_email": "Justin Furuness <jfuruness@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/f3/93/ce0573cbab68d85d57a5cef675d4b67b6762622c9b4e0ac294cb72bda807/lib_cidr_trie-1.2.8.tar.gz",
"platform": null,
"description": "Informational Badges:\n\n[![PyPI version](https://badge.fury.io/py/lib_cidr_trie.svg)](https://badge.fury.io/py/lib_cidr_trie)\n![PyPy](https://img.shields.io/badge/PyPy-7.3.17-blue)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/lib_cidr_trie)](https://pypi.org/project/lib_cidr_trie/)\n![Tests](https://github.com/jfuruness/lib_cidr_trie/actions/workflows/tests.yml/badge.svg)\n![Linux](https://img.shields.io/badge/os-Linux-blue.svg)\n![macOS Intel](https://img.shields.io/badge/os-macOS_Intel-lightgrey.svg)\n![macOS ARM](https://img.shields.io/badge/os-macOS_ARM-lightgrey.svg)\n\nSome Linting Badges (Where I could find them):\n\n[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![Checked with mypy](https://img.shields.io/badge/mypy-checked-2A6DBA.svg)](http://mypy-lang.org/)\n[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)\n[![Pylint](https://img.shields.io/badge/linting-pylint-yellowgreen)](https://github.com/pylint-dev/pylint/tree/main)\n[![try/except style: tryceratops](https://img.shields.io/badge/try%2Fexcept%20style-tryceratops%20%F0%9F%A6%96%E2%9C%A8-black)](https://github.com/guilatrova/tryceratops)\n\n# If you like this package please leave a github star so I know to continue maintaining it :)\n\n# lib\\_cidr\\_trie\nThis package contains a trie of prefixes for fast lookups\n\n* [Usage](#usage)\n* [Installation](#installation)\n* [Testing](#testing)\n* [Development/Contributing](#developmentcontributing)\n* [History](#history)\n* [Licence](#license)\n\n## Usage\n* [lib\\_cidr\\_trie](#lib_cidr_trie)\n\n```python\ntrie = IPv4CIDRTrie()\ncidrs = [ip_network(x) for x in [\"1.2.0.0/16\", \"1.2.3.0/24\", \"1.2.3.4\"]]\nfor cidr in cidrs:\n # for mypy\n assert isinstance(cidr, IPv4Network)\n trie.insert(cidr)\nfor cidr in cidrs:\n assert isinstance(cidr, IPv4Network)\n assert cidr in trie\n node = trie.get_most_specific_trie_supernet(cidr)\n assert node is not None and node.prefix == cidr\n\ninvalid_cidrs = [ip_network(x) for x in [\"1.0.0.0/8\", \"255.255.255.255\"]]\nfor invalid_cidr in invalid_cidrs:\n # for mypy\n assert isinstance(invalid_cidr, IPv4Network)\n assert invalid_cidr not in trie\n assert trie.get_most_specific_trie_supernet(invalid_cidr) is None\n\nassert IPv4Network(\"1.2.4.0/24\") in trie\nassert IPv4Network(\"1.2.0.255\") in trie\nassert IPv4Network(\"1.3.0.0/16\") not in trie\n```\n\n## Installation\n* [lib\\_cidr\\_trie](#lib_cidr_trie)\n\nInstall python and pip if you have not already. Then run:\n\n```bash\npip3 install lib_cidr_trie\n```\n\nThis will install the package and all of it's python dependencies.\n\nIf you want to install the project for development:\n```bash\ngit clone https://github.com/jfuruness/lib_cidr_trie.git\ncd lib_cidr_trie\npip3 install -e .[test]\npre-commit install\n```\n\nTo test the development package: [Testing](#testing)\n\n\n## Testing\n* [lib\\_cidr_trie](#lib_cidr_trie)\n\nTo test the package after installation:\n\n```\ncd lib_cidr_trie\npytest lib_cidr_trie\nruff check lib_cidr_trie\nruff format lib_cidr_trie\nmypy lib_cidr_trie\n```\n\nYou can run isolated builds across multiple environments with:\n\n```\ncd lib_cidr_trie\ntox --skip-missing-interpreters\n```\n\n## Development/Contributing\n* [lib\\_cidr\\_trie](#lib_cidr_trie)\n\n1. Fork it!\n2. Create your feature branch: `git checkout -b my-new-feature`\n3. Commit your changes: `git commit -am 'Add some feature'`\n4. Push to the branch: `git push origin my-new-feature`\n5. Submit a pull request\n6. Email me at jfuruness@gmail.com because I don't check github messages\n\n## History\n* [lib\\_cidr\\_trie](#lib_cidr_trie)\n\n* 1.2.8 Removed windows classifier from pyproject.toml\n* 1.2.7 Updated dependencies and ruff rules\n* 1.2.6 Fixed a bug in the pyproject.toml that screwed up non-local installs\n* 1.2.5 Updated README\n* 1.2.4 Updated docs and test deps\n* 1.2.3 Updated package metadata and fixed some formatting for linters\n* 1.1.2 Python version updates\n* 1.1.1 Dependency updates\n* 1.1.0 Removed a few type ignores for mypy, added PrefixType to dunder init\n* 1.0.0 Added linters, updated package structure, fixed typing issues\n* 0.0.3 Made it easier to subclass CIDRTrie\n* 0.0.2 README update\n* 0.0.1 First working version\n\n## License\n* [lib\\_cidr\\_trie](#lib_cidr_trie)\n\nBSD License (see license file)\n",
"bugtrack_url": null,
"license": "Copyright 2020 Justin Furuness Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ",
"summary": "Contains a trie of prefixes for fast lookups",
"version": "1.2.8",
"project_urls": {
"homepage": "https://github.com/jfuruness/lib_cidr_trie.git"
},
"split_keywords": [
"furuness",
" prefix",
" cidr",
" inet",
" trie",
" cidr-trie",
" roas",
" roas-trie",
" roas",
" roas-trie",
" bgp",
" hijack",
" roa",
" rov"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "9e3217eee7fb5bbf159ccf7d4de17de3579ddd192af740e9dfb9c518e18bcd7b",
"md5": "5f9b1000e70eb8154e9bbd347c4b6ea6",
"sha256": "ac8c5bbbb4f5cafbdd68e2a7c69476e6df4aed9e9e226872a582ea6018a076e2"
},
"downloads": -1,
"filename": "lib_cidr_trie-1.2.8-py3-none-any.whl",
"has_sig": false,
"md5_digest": "5f9b1000e70eb8154e9bbd347c4b6ea6",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 7900,
"upload_time": "2024-11-23T11:31:40",
"upload_time_iso_8601": "2024-11-23T11:31:40.581229Z",
"url": "https://files.pythonhosted.org/packages/9e/32/17eee7fb5bbf159ccf7d4de17de3579ddd192af740e9dfb9c518e18bcd7b/lib_cidr_trie-1.2.8-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f393ce0573cbab68d85d57a5cef675d4b67b6762622c9b4e0ac294cb72bda807",
"md5": "e7a2dbfa6d8dfa582c8bd39cea621048",
"sha256": "7690e11d8823695f402a048a3eed4f3c33fc50087b6c13483d14aadd7913da29"
},
"downloads": -1,
"filename": "lib_cidr_trie-1.2.8.tar.gz",
"has_sig": false,
"md5_digest": "e7a2dbfa6d8dfa582c8bd39cea621048",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 10894,
"upload_time": "2024-11-23T11:31:42",
"upload_time_iso_8601": "2024-11-23T11:31:42.186729Z",
"url": "https://files.pythonhosted.org/packages/f3/93/ce0573cbab68d85d57a5cef675d4b67b6762622c9b4e0ac294cb72bda807/lib_cidr_trie-1.2.8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-23 11:31:42",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "jfuruness",
"github_project": "lib_cidr_trie",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "lib-cidr-trie"
}