{ "info": { "author": "Agari Engineering", "author_email": "eng-team@agari.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: System :: Networking" ], "description": "ppy-radix\n=========\n\nppy-radix is a pure-Python fork of py-radix_, which implements the radix tree\ndata structure for the storage andretrieval of IPv4 and IPv6 network prefixes.\n\n.. _py-radix: https://github.com/mjschultz/py-radix\n\nThe radix tree is commonly used for routing table lookups. It efficiently\nstores network prefixes of varying lengths and allows fast lookups of\ncontaining networks.\n\n(In this fork, the C implementation has been removed in order to simplify use\nwith AWS Lambda in non-performance-critical cases. Otherwise this fork tracks\nthe upstream py-radix repo. The better solution would be to build a\n`manylinux1 wheel`__ for py-radix.)\n\n.. _manylinux1 wheel: https://github.com/mjschultz/py-radix/issues/30\n\nInstallation\n------------\n\nInstallation is a breeze via pip: ::\n\n pip install ppy-radix\n\nOr with the standard Python distutils incantation: ::\n\n\tpython setup.py build\n\tpython setup.py install\n\nTests are in the ``tests/`` directory and can be run with\n``python setup.py nosetests``.\n\nUsage\n-----\n\nA simple example that demonstrates most of the features: ::\n\n\timport radix\n\n\t# Create a new tree\n\trtree = radix.Radix()\n\n\t# Adding a node returns a RadixNode object. You can create\n\t# arbitrary members in its 'data' dict to store your data\n\trnode = rtree.add(\"10.0.0.0/8\")\n\trnode.data[\"blah\"] = \"whatever you want\"\n\n\t# You can specify nodes as CIDR addresses, or networks with\n\t# separate mask lengths. The following three invocations are\n\t# identical:\n\trnode = rtree.add(\"10.0.0.0/16\")\n\trnode = rtree.add(\"10.0.0.0\", 16)\n\trnode = rtree.add(network = \"10.0.0.0\", masklen = 16)\n\n\t# It is also possible to specify nodes using binary packed\n\t# addresses, such as those returned by the socket module\n\t# functions. In this case, the radix module will assume that\n\t# a four-byte address is an IPv4 address and a sixteen-byte\n\t# address is an IPv6 address. For example:\n\tbinary_addr = inet_ntoa(\"172.18.22.0\")\n\trnode = rtree.add(packed = binary_addr, masklen = 23)\n\n\t# Exact search will only return prefixes you have entered\n\t# You can use all of the above ways to specify the address\n\trnode = rtree.search_exact(\"10.0.0.0/8\")\n\t# Get your data back out\n\tprint rnode.data[\"blah\"]\n\t# Use a packed address\n\taddr = socket.inet_ntoa(\"10.0.0.0\")\n\trnode = rtree.search_exact(packed = addr, masklen = 8)\n\n\t# Best-match search will return the longest matching prefix\n\t# that contains the search term (routing-style lookup)\n\trnode = rtree.search_best(\"10.123.45.6\")\n\n\t# Worst-search will return the shortest matching prefix\n\t# that contains the search term (inverse routing-style lookup)\n\trnode = rtree.search_worst(\"10.123.45.6\")\n\n\t# Covered search will return all prefixes inside the given\n\t# search term, as a list (including the search term itself,\n\t# if present in the tree)\n\trnodes = rtree.search_covered(\"10.123.0.0/16\")\n\n\t# There are a couple of implicit members of a RadixNode:\n\tprint rnode.network\t# -> \"10.0.0.0\"\n\tprint rnode.prefix\t# -> \"10.0.0.0/8\"\n\tprint rnode.prefixlen\t# -> 8\n\tprint rnode.family\t# -> socket.AF_INET\n\tprint rnode.packed\t# -> '\\n\\x00\\x00\\x00'\n\n\t# IPv6 prefixes are fully supported in the same tree\n\trnode = rtree.add(\"2001:DB8::/3\")\n\trnode = rtree.add(\"::/0\")\n\n\t# Use the nodes() method to return all RadixNodes created\n\tnodes = rtree.nodes()\n\tfor rnode in nodes:\n\t\tprint rnode.prefix\n\n\t# The prefixes() method will return all the prefixes (as a\n\t# list of strings) that have been entered\n\tprefixes = rtree.prefixes()\n\n\t# You can also directly iterate over the tree itself\n\t# this would save some memory if the tree is big\n\t# NB. Don't modify the tree (add or delete nodes) while\n\t# iterating otherwise you will abort the iteration and\n\t# receive a RuntimeWarning. Changing a node's data dict\n\t# is permitted.\n\tfor rnode in rtree:\n \t\tprint rnode.prefix\n\n\nLicense\n-------\n\nppy-radix, like py-radix, is licensed under a ISC/BSD licence. The underlying\nradix tree implementation is taken (and modified) from MRTd and is subject to\na 4-term BSD license. See the LICENSE file for details.\n\nContributing\n------------\n\nPlease report bugs via GitHub to the original py-radix project at\nhttps://github.com/mjschultz/py-radix/issues.\nCode changes can be contributed through a pull request on GitHub or emailed\ndirectly to the upstream author .\n\nThe main portions of the directory tree are as follows: ::\n\n .\n \u251c\u2500\u2500 radix/*.py # Pure Python code\n \u251c\u2500\u2500 tests/ # Tests (regression and unit)\n \u2514\u2500\u2500 setup.py # Standard setup.py for installation/testing/etc.", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/agaridata/ppy-radix", "keywords": "radix tree trie python routing networking", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "ppy-radix", "package_url": "https://pypi.org/project/ppy-radix/", "platform": "", "project_url": "https://pypi.org/project/ppy-radix/", "project_urls": { "Homepage": "https://github.com/agaridata/ppy-radix" }, "release_url": "https://pypi.org/project/ppy-radix/0.10.0/", "requires_dist": null, "requires_python": "", "summary": "Pure-Python radix tree implementation", "version": "0.10.0" }, "last_serial": 3742133, "releases": { "0.10.0": [ { "comment_text": "", "digests": { "md5": "104077e5c3ef0599d2ef7af082b18b6a", "sha256": "5f64aa8e4aca812e5bd11f59c59d87f2658f155c0fb5c554c58270579c23054f" }, "downloads": -1, "filename": "ppy-radix-0.10.0.tar.gz", "has_sig": true, "md5_digest": "104077e5c3ef0599d2ef7af082b18b6a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10127, "upload_time": "2018-04-06T19:37:06", "url": "https://files.pythonhosted.org/packages/4f/39/63f94837a28cb07f7ad2fe6755af254f7f4685e820506c2678bde9da90f5/ppy-radix-0.10.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "104077e5c3ef0599d2ef7af082b18b6a", "sha256": "5f64aa8e4aca812e5bd11f59c59d87f2658f155c0fb5c554c58270579c23054f" }, "downloads": -1, "filename": "ppy-radix-0.10.0.tar.gz", "has_sig": true, "md5_digest": "104077e5c3ef0599d2ef7af082b18b6a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10127, "upload_time": "2018-04-06T19:37:06", "url": "https://files.pythonhosted.org/packages/4f/39/63f94837a28cb07f7ad2fe6755af254f7f4685e820506c2678bde9da90f5/ppy-radix-0.10.0.tar.gz" } ] }