[Python-modules-commits] [py-radix] 03/12: Import py-radix_0.10.0.orig.tar.gz

Apollon Oikonomopoulos apoikos at moszumanska.debian.org
Tue Jan 23 11:36:31 UTC 2018


This is an automated email from the git hooks/post-receive script.

apoikos pushed a commit to tag debian/0.10.0-1
in repository py-radix.

commit 95f0a8d24ac73ef821a4d0b3dcc33a79dd97a56a
Author: Aggelos Avgerinos <evaggelos.avgerinos at gmail.com>
Date:   Tue Jan 23 10:53:01 2018 +0200

    Import py-radix_0.10.0.orig.tar.gz
---
 ChangeLog                              |   78 ---
 LICENSE                                |   20 +-
 MANIFEST                               |    9 -
 MANIFEST.in                            |    3 +
 PKG-INFO                               |  172 +++++-
 README => README.rst                   |   77 ++-
 TODO                                   |   24 -
 inet_ntop.c                            |  201 -------
 py-radix.spec                          |   44 --
 py_radix.egg-info/PKG-INFO             |  160 +++++
 py_radix.egg-info/SOURCES.txt          |   14 +
 py_radix.egg-info/dependency_links.txt |    1 +
 py_radix.egg-info/top_level.txt        |    1 +
 radix.c                                |  675 ---------------------
 radix/__init__.py                      |   39 ++
 radix/_radix.c                         | 1015 ++++++++++++++++++++++++++++++++
 radix/_radix/radix.c                   |  920 +++++++++++++++++++++++++++++
 radix.h => radix/_radix/radix.h        |  110 ++--
 radix/radix.py                         |  536 +++++++++++++++++
 radix_python.c                         |  988 -------------------------------
 setup.cfg                              |   10 +
 setup.py                               |  102 ++--
 strlcpy.c                              |   51 --
 test.py                                |  353 -----------
 24 files changed, 3063 insertions(+), 2540 deletions(-)

diff --git a/ChangeLog b/ChangeLog
deleted file mode 100644
index 712617e..0000000
--- a/ChangeLog
+++ /dev/null
@@ -1,78 +0,0 @@
-20071218
- - (djm) Implement pickle protocol via __reduce__ and __setstate__, inspired
-   by wrapper from Erik Curiel (ecuriel AT kefta.com)
- - (djm) Crank version number to 0.5
- - (djm) Make this compile on Python 2.4, which lacks Py_ssize_t
-
-20071010
-- (djm) fix for Windows platforms: WSAStartup was not called, resulting
-  in failures inside getaddrinfo. Report from harpreet.sawhney AT gmail.com
-
-20060808
- - (djm) Support for Win32 (AF_INET6 is still broken though)
-
-20060628
- - (djm) Add RPM spec file
- - (djm) Hygene fixes: be more strict with types, use Python memory
-   allocators instead of libc malloc/free
-
-20050425
- - (djm) Fix bug that could corrupt some prefixes; reported by 
-   siganos AT cs.ucr.edu
- - (djm) Delete semicolons from EOL in test.py
- - (djm) Release py-radix-0.4
-
-20041123
- - (djm) Use RFC3849 IPv6 prefixes in documentation
- - (djm) Some stupid platforms still lack strl*, so avoid their use
- - (djm) Allow mixing of IPv4 and IPv6 prefixes in the same tree by keeping 
-   separate trees in the RadixObject for each AF
- - (djm) Release beta version: py-radix-0.3
-
-20041122
- - (djm) Raise a RuntimeWarning and abort iteration if the tree changes while
-   we are iterating over it
- - (djm) Add new regress tests: nodes() on an empty tree, iterate on an 
-   empty tree, modify tree while iterating, add/delete/check lots of prefixes
- - (djm) order and tidy regress test function names
- - (djm) Don't need to use a callback to do Radix.nodes(), so don't use one
- - (djm) Avoid callback for tree deletes too
- - (djm) GC unusued args to newRadixNodeObject
- - (djm) KNF and GC radix.h
- - (djm) unifdef radix.c
- - (djm) KNF radix.c (more remains)
- - (djm) Kill asserts() in radix.c, more KNF (starting to be readable now)
- - (djm) Implement Radix.prefixes() returning a list of prefix strings
- - (djm) Allow Radix methods to accept separate prefix lengths. E.g. 
-    method("xx.xx.xx.xx", yy)
- - (djm) Support keyword arguments for Radix methods. E.g. 
-   tree.add(network="127.0.0.1", masklen=32)
- - (djm) scrub off address bits past masklen, E.g. so tree.add("10.0.0.255/24")
-   creates an idential object to tree.add("10.0.0.0/24")
- - (djm) Regress tests for bad addresses and insane mask lengths
- - (djm) Support for binary packed addresses in Radix methods and a RadixNode
-    member
-
-20041121
- - (djm) Fix a bug: forgot to set the exception type when trying to get 
-   RadixNode members that don't exist
- - (djm) Prepare for Radix.method(address, masklen) by extending radix API
- - (djm) Add regression tests (not yet integrated with build)
- - (djm) Always allocate user objects in RadixNode
- - (djm) API change: don't allow creation of arbirtary members in RadixNode.
-   Instead, provide a data dict for storage of user-specified state. This 
-   avoid all of the introspection breakage of providing our get/setattr 
-   functions
- - (djm) Add RadixNode docstring
- - (djm) Add iterator support
- - (djm) Flesh out setup.py and add correct URL
- - (djm) Raise an exception when trying to mix V4 and V6 addresses in a single 
-   tree (rather than continuing and returning confusing results). Hopefully 
-   this will be fixed in the future
- - (djm) Release alpha version: py-radix-0.2
-
-20041118
- - (djm) Start the changelog
- - (djm) Release alpha version: py-radix-0.1
-
-$Id: ChangeLog,v 1.39 2007/12/18 02:49:01 djm Exp $
diff --git a/LICENSE b/LICENSE
index 6228d38..9b55be4 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,22 @@
-The Python binding code is subject to this license:
+The latest (post-2014) Python code is subject to this license:
+
+/*
+ * Copyright (c) 2014 Michael J. Schultz <mjschultz at gmail.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+The original (pre-2014) Python binding code is subject to this license:
 
 /*
  * Copyright (c) 2004 Damien Miller <djm at mindrot.org>
diff --git a/MANIFEST b/MANIFEST
deleted file mode 100644
index 07e9299..0000000
--- a/MANIFEST
+++ /dev/null
@@ -1,9 +0,0 @@
-ChangeLog
-LICENSE
-PKG-INFO
-README
-TODO
-radix.c
-radix.h
-radix_python.c
-setup.py
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..500c43f
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,3 @@
+include LICENSE
+include README.rst
+include radix/_radix/*
diff --git a/PKG-INFO b/PKG-INFO
index ee55130..4044b00 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,20 +1,160 @@
-Metadata-Version: 1.0
+Metadata-Version: 1.1
 Name: py-radix
-Version: 0.5
-Summary: Radix tree for storage and retrieval of network prefixes
-Home-page: http://www.mindrot.org/py-radix.html
-Author: Damien Miller
-Author-email: djm at mindrot.org
+Version: 0.10.0
+Summary: Radix tree implementation
+Home-page: https://github.com/mjschultz/py-radix
+Author: Michael J. Schultz
+Author-email: mjschultz at gmail.com
 License: BSD
-Download-URL: http://www2.mindrot.org/files/py-radix/
-Description: py-radix is an implementation of a radix tree data structure 
-             for the storage and retrieval of IPv4 and IPv6 network prefixes.
-	     The radix tree is the data structure most commonly used for 
-	     routing table lookups. It efficiently stores network prefixes of 
-	     varying lengths and allows fast lookups of containing networks.
-Keywords: radix,tree,python,routing
+Description-Content-Type: UNKNOWN
+Description: py-radix
+        ========
+        
+        .. image:: https://travis-ci.org/mjschultz/py-radix.svg?branch=master
+           :target: https://travis-ci.org/mjschultz/py-radix
+        
+        .. image:: https://coveralls.io/repos/mjschultz/py-radix/badge.png?branch=master
+           :target: https://coveralls.io/r/mjschultz/py-radix?branch=master
+        
+        py-radix implements the radix tree data structure for the storage and
+        retrieval of IPv4 and IPv6 network prefixes.
+        
+        The radix tree is commonly used for routing table lookups. It efficiently
+        stores network prefixes of varying lengths and allows fast lookups of
+        containing networks.
+        
+        Installation
+        ------------
+        
+        Installation is a breeze via pip: ::
+        
+            pip install py-radix
+        
+        Or with the standard Python distutils incantation: ::
+        
+        	python setup.py build
+        	python setup.py install
+        
+        The C extension will be built for supported python versions. If you do not
+        want the C extension, set the environment variable ``RADIX_NO_EXT=1``.
+        
+        Tests are in the ``tests/`` directory and can be run with
+        ``python setup.py nosetests``.
+        
+        Usage
+        -----
+        
+        A simple example that demonstrates most of the features: ::
+        
+        	import radix
+        
+        	# Create a new tree
+        	rtree = radix.Radix()
+        
+        	# Adding a node returns a RadixNode object. You can create
+        	# arbitrary members in its 'data' dict to store your data
+        	rnode = rtree.add("10.0.0.0/8")
+        	rnode.data["blah"] = "whatever you want"
+        
+        	# You can specify nodes as CIDR addresses, or networks with
+        	# separate mask lengths. The following three invocations are
+        	# identical:
+        	rnode = rtree.add("10.0.0.0/16")
+        	rnode = rtree.add("10.0.0.0", 16)
+        	rnode = rtree.add(network = "10.0.0.0", masklen = 16)
+        
+        	# It is also possible to specify nodes using binary packed
+        	# addresses, such as those returned by the socket module
+        	# functions. In this case, the radix module will assume that
+        	# a four-byte address is an IPv4 address and a sixteen-byte
+        	# address is an IPv6 address. For example:
+        	binary_addr = inet_ntoa("172.18.22.0")
+        	rnode = rtree.add(packed = binary_addr, masklen = 23)
+        
+        	# Exact search will only return prefixes you have entered
+        	# You can use all of the above ways to specify the address
+        	rnode = rtree.search_exact("10.0.0.0/8")
+        	# Get your data back out
+        	print rnode.data["blah"]
+        	# Use a packed address
+        	addr = socket.inet_ntoa("10.0.0.0")
+        	rnode = rtree.search_exact(packed = addr, masklen = 8)
+        
+        	# Best-match search will return the longest matching prefix
+        	# that contains the search term (routing-style lookup)
+        	rnode = rtree.search_best("10.123.45.6")
+        
+        	# Worst-search will return the shortest matching prefix
+        	# that contains the search term (inverse routing-style lookup)
+        	rnode = rtree.search_worst("10.123.45.6")
+        
+        	# Covered search will return all prefixes inside the given
+        	# search term, as a list (including the search term itself,
+        	# if present in the tree)
+        	rnodes = rtree.search_covered("10.123.0.0/16")
+        
+        	# There are a couple of implicit members of a RadixNode:
+        	print rnode.network	# -> "10.0.0.0"
+        	print rnode.prefix	# -> "10.0.0.0/8"
+        	print rnode.prefixlen	# -> 8
+        	print rnode.family	# -> socket.AF_INET
+        	print rnode.packed	# -> '\n\x00\x00\x00'
+        
+        	# IPv6 prefixes are fully supported in the same tree
+        	rnode = rtree.add("2001:DB8::/3")
+        	rnode = rtree.add("::/0")
+        
+        	# Use the nodes() method to return all RadixNodes created
+        	nodes = rtree.nodes()
+        	for rnode in nodes:
+        		print rnode.prefix
+        
+        	# The prefixes() method will return all the prefixes (as a
+        	# list of strings) that have been entered
+        	prefixes = rtree.prefixes()
+        
+        	# You can also directly iterate over the tree itself
+        	# this would save some memory if the tree is big
+        	# NB. Don't modify the tree (add or delete nodes) while
+        	# iterating otherwise you will abort the iteration and
+        	# receive a RuntimeWarning. Changing a node's data dict
+        	# is permitted.
+        	for rnode in rtree:
+          		print rnode.prefix
+        
+        
+        License
+        -------
+        
+        py-radix is licensed under a ISC/BSD licence. The underlying radix tree 
+        implementation is taken (and modified) from MRTd and is subject to a 4-term 
+        BSD license. See the LICENSE file for details.
+        
+        Contributing
+        ------------
+        
+        Please report bugs via GitHub at https://github.com/mjschultz/py-radix/issues.
+        Code changes can be contributed through a pull request on GitHub or emailed
+        directly to me <mjschultz at gmail.com>.
+        
+        The main portions of the directory tree are as follows: ::
+        
+            .
+            ├── radix/*.py      # Pure Python code
+            ├── radix/_radix.c  # C extension code (compatible with pure python code)
+            ├── radix/_radix/*  # C extension code (compatible with pure python code)
+            ├── tests/          # Tests (regression and unit)
+            └── setup.py        # Standard setup.py for installation/testing/etc.
+        
+Keywords: radix tree trie python routing networking
+Platform: UNKNOWN
 Classifier: Intended Audience :: Developers
-Classifier: License :: OSI Approved :: BSD License
-Classifier: Natural Language :: English
-Classifier: Programming Language :: Python
 Classifier: Topic :: Software Development :: Libraries :: Python Modules
+Classifier: Topic :: System :: Networking
+Classifier: License :: OSI Approved :: BSD License
+Classifier: Programming Language :: Python :: 2
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3
+Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
diff --git a/README b/README.rst
similarity index 55%
rename from README
rename to README.rst
index 3a99e30..40f4754 100644
--- a/README
+++ b/README.rst
@@ -1,26 +1,41 @@
-py-radix is an implementation of a radix tree data structure for the storage 
-and retrieval of IPv4 and IPv6 network prefixes.
+py-radix
+========
 
-The radix tree is the data structure most commonly used for routing table 
-lookups. It efficiently stores network prefixes of varying lengths and 
-allows fast lookups of containing networks.
+.. image:: https://travis-ci.org/mjschultz/py-radix.svg?branch=master
+   :target: https://travis-ci.org/mjschultz/py-radix
 
-To install, use the standard Python distutils incantation:
+.. image:: https://coveralls.io/repos/mjschultz/py-radix/badge.png?branch=master
+   :target: https://coveralls.io/r/mjschultz/py-radix?branch=master
+
+py-radix implements the radix tree data structure for the storage and
+retrieval of IPv4 and IPv6 network prefixes.
+
+The radix tree is commonly used for routing table lookups. It efficiently
+stores network prefixes of varying lengths and allows fast lookups of
+containing networks.
+
+Installation
+------------
+
+Installation is a breeze via pip: ::
+
+    pip install py-radix
+
+Or with the standard Python distutils incantation: ::
 
 	python setup.py build
 	python setup.py install
 
-Regression tests are in the test.py file.
+The C extension will be built for supported python versions. If you do not
+want the C extension, set the environment variable ``RADIX_NO_EXT=1``.
 
-py-radix is licensed under a ISC/BSD licence. The underlying radix tree 
-implementation is taken (and modified) from MRTd and is subject to a 4-term 
-BSD license. See the LICENSE file for details.
+Tests are in the ``tests/`` directory and can be run with
+``python setup.py nosetests``.
 
-Please report bugs to Damien Miller <djm at mindrot.org>. Please check the TODO
-file first, in case your problem is something I already know about (please
-send patches!)
+Usage
+-----
 
-A simple example that demonstrates most of the features:
+A simple example that demonstrates most of the features: ::
 
 	import radix
 
@@ -60,6 +75,15 @@ A simple example that demonstrates most of the features:
 	# that contains the search term (routing-style lookup)
 	rnode = rtree.search_best("10.123.45.6")
 
+	# Worst-search will return the shortest matching prefix
+	# that contains the search term (inverse routing-style lookup)
+	rnode = rtree.search_worst("10.123.45.6")
+
+	# Covered search will return all prefixes inside the given
+	# search term, as a list (including the search term itself,
+	# if present in the tree)
+	rnodes = rtree.search_covered("10.123.0.0/16")
+
 	# There are a couple of implicit members of a RadixNode:
 	print rnode.network	# -> "10.0.0.0"
 	print rnode.prefix	# -> "10.0.0.0/8"
@@ -74,7 +98,7 @@ A simple example that demonstrates most of the features:
 	# Use the nodes() method to return all RadixNodes created
 	nodes = rtree.nodes()
 	for rnode in nodes:
-  		print rnode.prefix
+		print rnode.prefix
 
 	# The prefixes() method will return all the prefixes (as a
 	# list of strings) that have been entered
@@ -90,4 +114,25 @@ A simple example that demonstrates most of the features:
   		print rnode.prefix
 
 
-$Id: README,v 1.12 2004/11/24 20:46:18 djm Exp $
+License
+-------
+
+py-radix is licensed under a ISC/BSD licence. The underlying radix tree 
+implementation is taken (and modified) from MRTd and is subject to a 4-term 
+BSD license. See the LICENSE file for details.
+
+Contributing
+------------
+
+Please report bugs via GitHub at https://github.com/mjschultz/py-radix/issues.
+Code changes can be contributed through a pull request on GitHub or emailed
+directly to me <mjschultz at gmail.com>.
+
+The main portions of the directory tree are as follows: ::
+
+    .
+    ├── radix/*.py      # Pure Python code
+    ├── radix/_radix.c  # C extension code (compatible with pure python code)
+    ├── radix/_radix/*  # C extension code (compatible with pure python code)
+    ├── tests/          # Tests (regression and unit)
+    └── setup.py        # Standard setup.py for installation/testing/etc.
diff --git a/TODO b/TODO
deleted file mode 100644
index 83bb387..0000000
--- a/TODO
+++ /dev/null
@@ -1,24 +0,0 @@
-Fix bug(?) on Win32: getaddrinfo doesn't seem to parse IPv6 addresses
-
-- Maybe Extend Radix methods to accept (network, mask) (contiguous masks only)
-
-- tree.delete(RadixNode)
-
-tree.copy()
-
-more KNF
-
-tree.search_all_containing(network) -> [ network, network ] (sorted by prefix)
-(use search_best2 internally)
-
-tree.search_containing(network) -> RadixNode or None
- Find the prefix containing 'network', not including an exact match. 
-
-tree.num_prefixes()
-
-dict-like interface:
-	tree[addr] = user_object
-
-"blur" prefix - reduce masklen
-
-$Id: TODO,v 1.24 2007/12/18 00:53:53 djm Exp $
diff --git a/inet_ntop.c b/inet_ntop.c
deleted file mode 100644
index d3db3ce..0000000
--- a/inet_ntop.c
+++ /dev/null
@@ -1,201 +0,0 @@
-/*	$OpenBSD: inet_ntop.c,v 1.7 2005/08/06 20:30:03 espie Exp $	*/
-
-/* Copyright (c) 1996 by Internet Software Consortium.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
- * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
- * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
- * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- */
-
-#include "radix.h"
-#include <sys/types.h>
-#include <string.h>
-#include <errno.h>
-#include <stdio.h>
-
-#ifndef EAFNOSUPPORT
-# define EAFNOSUPPORT EINVAL
-#endif
-#ifndef IN6ADDRSZ
-# define IN6ADDRSZ 16
-#endif
-#ifndef INT16SZ
-# define INT16SZ 2
-#endif
-
-/*
- * WARNING: Don't even consider trying to compile this on a system where
- * sizeof(int) < 4.  sizeof(int) > 4 is fine; all the world's not a VAX.
- */
-
-static const char *inet_ntop4(const u_char *src, char *dst, size_t size);
-static const char *inet_ntop6(const u_char *src, char *dst, size_t size);
-
-/* char *
- * inet_ntop(af, src, dst, size)
- *	convert a network format address to presentation format.
- * return:
- *	pointer to presentation format address (`dst'), or NULL (see errno).
- * author:
- *	Paul Vixie, 1996.
- */
-const char *
-inet_ntop(int af, const void *src, char *dst, size_t size)
-{
-	switch (af) {
-	case AF_INET:
-		return (inet_ntop4(src, dst, size));
-	case AF_INET6:
-		return (inet_ntop6(src, dst, size));
-	default:
-		errno = EAFNOSUPPORT;
-		return (NULL);
-	}
-	/* NOTREACHED */
-}
-
-/* const char *
- * inet_ntop4(src, dst, size)
- *	format an IPv4 address, more or less like inet_ntoa()
- * return:
- *	`dst' (as a const)
- * notes:
- *	(1) uses no statics
- *	(2) takes a u_char* not an in_addr as input
- * author:
- *	Paul Vixie, 1996.
- */
-static const char *
-inet_ntop4(const u_char *src, char *dst, size_t size)
-{
-	static const char fmt[] = "%u.%u.%u.%u";
-	char tmp[sizeof "255.255.255.255"];
-	int l;
-
-	l = snprintf(tmp, size, fmt, src[0], src[1], src[2], src[3]);
-	if (l <= 0 || (unsigned)l >= size) {
-		errno = ENOSPC;
-		return (NULL);
-	}
-	strlcpy(dst, tmp, size);
-	return (dst);
-}
-
-/* const char *
- * inet_ntop6(src, dst, size)
- *	convert IPv6 binary address into presentation (printable) format
- * author:
- *	Paul Vixie, 1996.
- */
-static const char *
-inet_ntop6(const u_char *src, char *dst, size_t size)
-{
-	/*
-	 * Note that int32_t and int16_t need only be "at least" large enough
-	 * to contain a value of the specified size.  On some systems, like
-	 * Crays, there is no such thing as an integer variable with 16 bits.
-	 * Keep this in mind if you think this function should have been coded
-	 * to use pointer overlays.  All the world's not a VAX.
-	 */
-	char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"];
-	char *tp, *ep;
-	struct { int base, len; } best, cur;
-	u_int words[IN6ADDRSZ / INT16SZ];
-	int i;
-	int advance;
-
-	/*
-	 * Preprocess:
-	 *	Copy the input (bytewise) array into a wordwise array.
-	 *	Find the longest run of 0x00's in src[] for :: shorthanding.
-	 */
-	memset(words, '\0', sizeof words);
-	for (i = 0; i < IN6ADDRSZ; i++)
-		words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3));
-	best.base = -1;
-	cur.base = -1;
-	for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++) {
-		if (words[i] == 0) {
-			if (cur.base == -1)
-				cur.base = i, cur.len = 1;
-			else
-				cur.len++;
-		} else {
-			if (cur.base != -1) {
-				if (best.base == -1 || cur.len > best.len)
-					best = cur;
-				cur.base = -1;
-			}
-		}
-	}
-	if (cur.base != -1) {
-		if (best.base == -1 || cur.len > best.len)
-			best = cur;
-	}
-	if (best.base != -1 && best.len < 2)
-		best.base = -1;
-
-	/*
-	 * Format the result.
-	 */
-	tp = tmp;
-	ep = tmp + sizeof(tmp);
-	for (i = 0; i < (IN6ADDRSZ / INT16SZ) && tp < ep; i++) {
-		/* Are we inside the best run of 0x00's? */
-		if (best.base != -1 && i >= best.base &&
-		    i < (best.base + best.len)) {
-			if (i == best.base) {
-				if (tp + 1 >= ep)
-					return (NULL);
-				*tp++ = ':';
-			}
-			continue;
-		}
-		/* Are we following an initial run of 0x00s or any real hex? */
-		if (i != 0) {
-			if (tp + 1 >= ep)
-				return (NULL);
-			*tp++ = ':';
-		}
-		/* Is this address an encapsulated IPv4? */
-		if (i == 6 && best.base == 0 &&
-		    (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) {
-			if (!inet_ntop4(src+12, tp, (size_t)(ep - tp)))
-				return (NULL);
-			tp += strlen(tp);
-			break;
-		}
-		advance = snprintf(tp, ep - tp, "%x", words[i]);
-		if (advance <= 0 || advance >= ep - tp)
-			return (NULL);
-		tp += advance;
-	}
-	/* Was it a trailing run of 0x00's? */
-	if (best.base != -1 && (best.base + best.len) == (IN6ADDRSZ / INT16SZ)) {
-		if (tp + 1 >= ep)
-			return (NULL);
-		*tp++ = ':';
-	}
-	if (tp + 1 >= ep)
-		return (NULL);
-	*tp++ = '\0';
-
-	/*
-	 * Check for overflow, copy, and we're done.
-	 */
-	if ((size_t)(tp - tmp) > size) {
-		errno = ENOSPC;
-		return (NULL);
-	}
-	strlcpy(dst, tmp, size);
-	return (dst);
-}
diff --git a/py-radix.spec b/py-radix.spec
deleted file mode 100644
index a6d41b3..0000000
--- a/py-radix.spec
+++ /dev/null
@@ -1,44 +0,0 @@
-Name: py-radix
-Summary: Radix tree data structure for Python
-Version: 0.5
-Release: 1
-Source0: http://www2.mindrot.org/files/py-radix/py-radix-%{version}.tar.gz
-License: BSD
-Group: Development/Libraries
-BuildRoot: %{_tmppath}/%{name}-buildroot
-Requires: %{__python}
-BuildRequires: python-devel, gcc
-Url: http://www.mindrot.org/py-radix.html
-
-%description
-py-radix is an implementation of a radix tree for Python, which 
-supports storage and lookups of IPv4 and IPv6 networks. 
-
-The radix tree (a.k.a Patricia tree) is the data structure most 
-commonly used for routing table lookups. It efficiently stores 
-network prefixes of varying lengths and allows fast lookups of 
-containing networks. py-radix's implementation is built solely 
-for networks (the data structure itself is more general). 
-
-%prep
-%setup
-
-%build
-%{__python} setup.py build
-
-%install
-%{__python} setup.py install --root=$RPM_BUILD_ROOT --record=INSTALLED_FILES
-sed -e 's|/[^/]*$||' INSTALLED_FILES | grep "site-packages/" | \
-    sort | uniq | awk '{ print "%attr(755,root,root) %dir " $1}' > INSTALLED_DIRS
-cat INSTALLED_FILES INSTALLED_DIRS > INSTALLED_OBJECTS
-
-%clean
-rm -rf $RPM_BUILD_ROOT
-
-%files -f INSTALLED_OBJECTS
-%defattr(-,root,root)
-%doc LICENSE README TODO ChangeLog
-
-%changelog
-* Wed Jun 28 2006 Damien Miller <djm at mindrot.org>
-- Build RPM
diff --git a/py_radix.egg-info/PKG-INFO b/py_radix.egg-info/PKG-INFO
new file mode 100644
index 0000000..4044b00
--- /dev/null
+++ b/py_radix.egg-info/PKG-INFO
@@ -0,0 +1,160 @@
+Metadata-Version: 1.1
+Name: py-radix
+Version: 0.10.0
+Summary: Radix tree implementation
+Home-page: https://github.com/mjschultz/py-radix
+Author: Michael J. Schultz
+Author-email: mjschultz at gmail.com
+License: BSD
+Description-Content-Type: UNKNOWN
+Description: py-radix
+        ========
+        
+        .. image:: https://travis-ci.org/mjschultz/py-radix.svg?branch=master
+           :target: https://travis-ci.org/mjschultz/py-radix
+        
+        .. image:: https://coveralls.io/repos/mjschultz/py-radix/badge.png?branch=master
+           :target: https://coveralls.io/r/mjschultz/py-radix?branch=master
+        
+        py-radix implements the radix tree data structure for the storage and
+        retrieval of IPv4 and IPv6 network prefixes.
+        
+        The radix tree is commonly used for routing table lookups. It efficiently
+        stores network prefixes of varying lengths and allows fast lookups of
+        containing networks.
+        
+        Installation
+        ------------
+        
+        Installation is a breeze via pip: ::
+        
+            pip install py-radix
+        
+        Or with the standard Python distutils incantation: ::
+        
+        	python setup.py build
+        	python setup.py install
+        
+        The C extension will be built for supported python versions. If you do not
+        want the C extension, set the environment variable ``RADIX_NO_EXT=1``.
+        
+        Tests are in the ``tests/`` directory and can be run with
+        ``python setup.py nosetests``.
+        
+        Usage
+        -----
+        
+        A simple example that demonstrates most of the features: ::
+        
+        	import radix
+        
+        	# Create a new tree
+        	rtree = radix.Radix()
+        
+        	# Adding a node returns a RadixNode object. You can create
+        	# arbitrary members in its 'data' dict to store your data
+        	rnode = rtree.add("10.0.0.0/8")
+        	rnode.data["blah"] = "whatever you want"
+        
+        	# You can specify nodes as CIDR addresses, or networks with
+        	# separate mask lengths. The following three invocations are
+        	# identical:
+        	rnode = rtree.add("10.0.0.0/16")
+        	rnode = rtree.add("10.0.0.0", 16)
+        	rnode = rtree.add(network = "10.0.0.0", masklen = 16)
+        
+        	# It is also possible to specify nodes using binary packed
+        	# addresses, such as those returned by the socket module
+        	# functions. In this case, the radix module will assume that
+        	# a four-byte address is an IPv4 address and a sixteen-byte
+        	# address is an IPv6 address. For example:
+        	binary_addr = inet_ntoa("172.18.22.0")
+        	rnode = rtree.add(packed = binary_addr, masklen = 23)
+        
+        	# Exact search will only return prefixes you have entered
+        	# You can use all of the above ways to specify the address
+        	rnode = rtree.search_exact("10.0.0.0/8")
+        	# Get your data back out
+        	print rnode.data["blah"]
+        	# Use a packed address
+        	addr = socket.inet_ntoa("10.0.0.0")
+        	rnode = rtree.search_exact(packed = addr, masklen = 8)
+        
+        	# Best-match search will return the longest matching prefix
+        	# that contains the search term (routing-style lookup)
+        	rnode = rtree.search_best("10.123.45.6")
+        
+        	# Worst-search will return the shortest matching prefix
+        	# that contains the search term (inverse routing-style lookup)
+        	rnode = rtree.search_worst("10.123.45.6")
+        
+        	# Covered search will return all prefixes inside the given
+        	# search term, as a list (including the search term itself,
+        	# if present in the tree)
+        	rnodes = rtree.search_covered("10.123.0.0/16")
+        
+        	# There are a couple of implicit members of a RadixNode:
+        	print rnode.network	# -> "10.0.0.0"
+        	print rnode.prefix	# -> "10.0.0.0/8"
+        	print rnode.prefixlen	# -> 8
+        	print rnode.family	# -> socket.AF_INET
+        	print rnode.packed	# -> '\n\x00\x00\x00'
+        
+        	# IPv6 prefixes are fully supported in the same tree
+        	rnode = rtree.add("2001:DB8::/3")
+        	rnode = rtree.add("::/0")
+        
+        	# Use the nodes() method to return all RadixNodes created
+        	nodes = rtree.nodes()
+        	for rnode in nodes:
+        		print rnode.prefix
+        
+        	# The prefixes() method will return all the prefixes (as a
+        	# list of strings) that have been entered
+        	prefixes = rtree.prefixes()
+        
+        	# You can also directly iterate over the tree itself
+        	# this would save some memory if the tree is big
+        	# NB. Don't modify the tree (add or delete nodes) while
+        	# iterating otherwise you will abort the iteration and
+        	# receive a RuntimeWarning. Changing a node's data dict
+        	# is permitted.
+        	for rnode in rtree:
+          		print rnode.prefix
+        
+        
+        License
+        -------
+        
+        py-radix is licensed under a ISC/BSD licence. The underlying radix tree 
+        implementation is taken (and modified) from MRTd and is subject to a 4-term 
+        BSD license. See the LICENSE file for details.
+        
+        Contributing
+        ------------
+        
+        Please report bugs via GitHub at https://github.com/mjschultz/py-radix/issues.
+        Code changes can be contributed through a pull request on GitHub or emailed
+        directly to me <mjschultz at gmail.com>.
+        
+        The main portions of the directory tree are as follows: ::
+        
+            .
+            ├── radix/*.py      # Pure Python code
+            ├── radix/_radix.c  # C extension code (compatible with pure python code)
+            ├── radix/_radix/*  # C extension code (compatible with pure python code)
+            ├── tests/          # Tests (regression and unit)
+            └── setup.py        # Standard setup.py for installation/testing/etc.
+        
+Keywords: radix tree trie python routing networking
+Platform: UNKNOWN
+Classifier: Intended Audience :: Developers
+Classifier: Topic :: Software Development :: Libraries :: Python Modules
+Classifier: Topic :: System :: Networking
+Classifier: License :: OSI Approved :: BSD License
+Classifier: Programming Language :: Python :: 2
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3
+Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
diff --git a/py_radix.egg-info/SOURCES.txt b/py_radix.egg-info/SOURCES.txt
new file mode 100644
index 0000000..07c665a
--- /dev/null
+++ b/py_radix.egg-info/SOURCES.txt
@@ -0,0 +1,14 @@
+LICENSE
+MANIFEST.in
+README.rst
+setup.cfg
+setup.py
+py_radix.egg-info/PKG-INFO
+py_radix.egg-info/SOURCES.txt
+py_radix.egg-info/dependency_links.txt
+py_radix.egg-info/top_level.txt
+radix/__init__.py
+radix/_radix.c
+radix/radix.py
+radix/_radix/radix.c
+radix/_radix/radix.h
\ No newline at end of file
diff --git a/py_radix.egg-info/dependency_links.txt b/py_radix.egg-info/dependency_links.txt
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/py_radix.egg-info/dependency_links.txt
@@ -0,0 +1 @@
+
diff --git a/py_radix.egg-info/top_level.txt b/py_radix.egg-info/top_level.txt
new file mode 100644
index 0000000..4e0dc5f
--- /dev/null
+++ b/py_radix.egg-info/top_level.txt
@@ -0,0 +1 @@
+radix
diff --git a/radix.c b/radix.c
deleted file mode 100644
index fbb4244..0000000
--- a/radix.c
+++ /dev/null
@@ -1,675 +0,0 @@
-/*
- * Copyright (c) 1999-2000
- *
- * The Regents of the University of Michigan ("The Regents") and
- * Merit Network, Inc. All rights reserved.  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. All advertising materials mentioning features or use of
- * this software must display the following acknowledgement:
- *
- *   This product includes software developed by the University of
- *   Michigan, Merit Network, Inc., and their contributors.
- *
- * 4. Neither the name of the University, Merit Network, nor the
- * names of their contributors may be used to endorse or
- * promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 TH E REGENTS
- * 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) HO WEVER 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.
- */
-/*
... 4881 lines suppressed ...

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/py-radix.git



More information about the Python-modules-commits mailing list