lib-cidr-trie


Namelib-cidr-trie JSON
Version 1.2.2 PyPI version JSON
download
home_page
SummaryContains a trie of prefixes for fast lookups
upload_time2024-02-23 04:01:38
maintainer
docs_urlNone
author
requires_python>=3.10
licenseCopyright 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.
            [![Python 3.10](https://img.shields.io/badge/python-3.10-blue.svg)](https://www.python.org/downloads/release/python-3100/)
[![Python 3.11](https://img.shields.io/badge/python-3.11-blue.svg)](https://www.python.org/downloads/release/python-3110/)
[![Python 3.12](https://img.shields.io/badge/python-3.12-blue.svg)](https://www.python.org/downloads/release/python-3120/)
![Tests](https://github.com/jfuruness/bgpy/actions/workflows/tests.yml/badge.svg)
[![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/)

# 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 roa_collector
pytest roa_collector
ruff roa_collector
black roa_collector
mypy roa_collector
```

If you want to run it across multiple environments, and have python 3.10 and 3.11 installed:

```
cd roa_collector
tox
```

## 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.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": "",
    "name": "lib-cidr-trie",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "",
    "keywords": "Furuness,prefix,cidr,inet,trie,cidr-trie,roas,roas-trie,ROAs,ROAs-trie,BGP,Hijack,ROA,ROV",
    "author": "",
    "author_email": "Justin Furuness <jfuruness@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/a3/08/db6e111c7d84d85c32fcf50c023deb9ae70bc99963455d74d24f1428fec9/lib_cidr_trie-1.2.2.tar.gz",
    "platform": null,
    "description": "[![Python 3.10](https://img.shields.io/badge/python-3.10-blue.svg)](https://www.python.org/downloads/release/python-3100/)\n[![Python 3.11](https://img.shields.io/badge/python-3.11-blue.svg)](https://www.python.org/downloads/release/python-3110/)\n[![Python 3.12](https://img.shields.io/badge/python-3.12-blue.svg)](https://www.python.org/downloads/release/python-3120/)\n![Tests](https://github.com/jfuruness/bgpy/actions/workflows/tests.yml/badge.svg)\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\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 roa_collector\npytest roa_collector\nruff roa_collector\nblack roa_collector\nmypy roa_collector\n```\n\nIf you want to run it across multiple environments, and have python 3.10 and 3.11 installed:\n\n```\ncd roa_collector\ntox\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.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.2",
    "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": "eefc4204f045140b67f8f17163bba31ce7eb8861b704737ba2e3d0565cb6fc22",
                "md5": "55b79ad815ef90c75e43c410df338dd6",
                "sha256": "f79859812920bd5980c6595e51527988e101b9e180fc908722920f2ee945cd02"
            },
            "downloads": -1,
            "filename": "lib_cidr_trie-1.2.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "55b79ad815ef90c75e43c410df338dd6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 7410,
            "upload_time": "2024-02-23T04:01:37",
            "upload_time_iso_8601": "2024-02-23T04:01:37.076476Z",
            "url": "https://files.pythonhosted.org/packages/ee/fc/4204f045140b67f8f17163bba31ce7eb8861b704737ba2e3d0565cb6fc22/lib_cidr_trie-1.2.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a308db6e111c7d84d85c32fcf50c023deb9ae70bc99963455d74d24f1428fec9",
                "md5": "7a222381f5a1aab9f5311d5c8727a6b2",
                "sha256": "35e46fafa8b50c934fe39073eae5f66075ec63dca6b31a7ead1854d7e079faa1"
            },
            "downloads": -1,
            "filename": "lib_cidr_trie-1.2.2.tar.gz",
            "has_sig": false,
            "md5_digest": "7a222381f5a1aab9f5311d5c8727a6b2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 7267,
            "upload_time": "2024-02-23T04:01:38",
            "upload_time_iso_8601": "2024-02-23T04:01:38.855459Z",
            "url": "https://files.pythonhosted.org/packages/a3/08/db6e111c7d84d85c32fcf50c023deb9ae70bc99963455d74d24f1428fec9/lib_cidr_trie-1.2.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-23 04:01:38",
    "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"
}
        
Elapsed time: 0.19521s