Skip to content

Commit

Permalink
Cleanup and move files
Browse files Browse the repository at this point in the history
  • Loading branch information
mjschultz committed Apr 19, 2014
1 parent fe56ffc commit f1b19a6
Show file tree
Hide file tree
Showing 12 changed files with 151 additions and 198 deletions.
53 changes: 53 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]

# C extensions
*.so

# Distribution / packaging
.Python
env/
bin/
build/
develop-eggs/
dist/
eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.cache
nosetests.xml
coverage.xml

# Translations
*.mo

# Mr Developer
.mr.developer.cfg
.project
.pydevproject

# Rope
.ropeproject

# Django stuff:
*.log
*.pot

# Sphinx documentation
docs/_build/
20 changes: 19 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
*
* 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 <[email protected]>
Expand Down
55 changes: 40 additions & 15 deletions README → README.rst
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
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.
py-radix implements the radix tree data structure for the storage and
retrieval of IPv4 and IPv6 network prefixes.

To install, use the standard Python distutils incantation:
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.

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 test`.

Please report bugs to Damien Miller <[email protected]>. 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:

Expand Down Expand Up @@ -90,4 +95,24 @@ 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 <[email protected]>.

The main portions of the directory tree are as follows:

.
├── radix/ # Pure Python code
├── lib/ # C extension code (compatible with pure python code)
├── tests/ # Tests (regression and unit)
└── setup.py # Standard setup.py for installation/testing/etc.
44 changes: 0 additions & 44 deletions packaging/py-radix.spec

This file was deleted.

7 changes: 7 additions & 0 deletions radix/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
try:
from _radix import *
except Exception as e:
print 'C extension not found'
print e

__version__ = '0.6.0'
File renamed without changes.
57 changes: 12 additions & 45 deletions radix/radix_python.c → radix/_radix/python.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
#include "structmember.h"
#include "radix.h"

/* $Id: radix_python.c,v 1.30 2007/12/18 02:49:01 djm Exp $ */

/* Prototypes */
struct _RadixObject;
struct _RadixIterObject;
Expand Down Expand Up @@ -842,16 +840,16 @@ PyDoc_STRVAR(radix_Radix_doc,
\n\
Instantiate a new radix tree object.");

static PyObject *
radix_Radix(PyObject *self, PyObject *args)
{
static PyObject * radix_Radix(PyObject *self, PyObject *args) {
RadixObject *rv;

if (!PyArg_ParseTuple(args, ":Radix"))
if (!PyArg_ParseTuple(args, ":Radix")) {
return NULL;
}
rv = newRadixObject();
if (rv == NULL)
if (rv == NULL) {
return NULL;
}
return (PyObject *)rv;
}

Expand Down Expand Up @@ -937,52 +935,21 @@ PyDoc_STRVAR(module_doc,
" print rnode.prefix\n"
);

#if defined(_MSC_VER)
static void cleanupradix(void)
{
WSACleanup();
}
#endif

PyMODINIT_FUNC
initradix(void)
{
PyMODINIT_FUNC initradix(void) {
PyObject *m, *d;
#if defined(_MSC_VER)
WSADATA winsock_data;
int r;
char errbuf[256];

r = WSAStartup(0x0202, &winsock_data);
switch (r) {
case 0:
Py_AtExit(cleanupradix);
break;
case WSASYSNOTREADY:
PyErr_SetString(PyExc_ImportError, "Winsock error: "
"network subsystem not ready");
return;
case WSAEINVAL:
case WSAVERNOTSUPPORTED:
PyErr_SetString(PyExc_ImportError, "Winsock error: "
"required winsock version 2.2 not supported");
return;
default:
snprintf(errbuf, sizeof(errbuf), "Winsock error: code %d", r);
PyErr_SetString(PyExc_ImportError, errbuf);
return;
}
#endif

if (PyType_Ready(&Radix_Type) < 0)
if (PyType_Ready(&Radix_Type) < 0) {
return;
if (PyType_Ready(&RadixNode_Type) < 0)
}
if (PyType_Ready(&RadixNode_Type) < 0) {
return;
}

m = Py_InitModule3("radix", radix_methods, module_doc);

/* Stash the callable constructor for use in Radix.__reduce__ */
d = PyModule_GetDict(m);
radix_constructor = PyDict_GetItemString(d, "Radix");

PyModule_AddStringConstant(m, "__version__", "0.4");
PyModule_AddIntConstant(m, "__accelerator__", 1);
}
File renamed without changes.
File renamed without changes.
51 changes: 0 additions & 51 deletions radix/strlcpy.c

This file was deleted.

Loading

0 comments on commit f1b19a6

Please sign in to comment.