unexpose / remove extraneous C helpers that were only useful during development
This commit is contained in:
parent
7731009780
commit
504c8fc942
@ -52,28 +52,6 @@ static char* shuffle_oid(const char* oid) {
|
||||
return shuffled;
|
||||
}
|
||||
|
||||
static PyObject* _cbson_shuffle_oid(PyObject* self, PyObject* args) {
|
||||
char* data;
|
||||
int length;
|
||||
if (!PyArg_ParseTuple(args, "s#", &data, &length)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (length != 12) {
|
||||
PyErr_SetString(PyExc_ValueError, "oid must be of length 12");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char* shuffled = shuffle_oid(data);
|
||||
if (!shuffled) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PyObject* result = Py_BuildValue("s#", shuffled, 12);
|
||||
free(shuffled);
|
||||
return result;
|
||||
}
|
||||
|
||||
static PyObject* build_element(const char type, const char* name, const int length, const char* data) {
|
||||
int name_length = strlen(name) + 1;
|
||||
int built_length = 1 + name_length + length;
|
||||
@ -381,10 +359,6 @@ static PyObject* _cbson_dict_to_bson(PyObject* self, PyObject* dict) {
|
||||
}
|
||||
|
||||
static PyMethodDef _CBSONMethods[] = {
|
||||
{"_shuffle_oid", _cbson_shuffle_oid, METH_VARARGS,
|
||||
"shuffle an ObjectId into proper byte order."},
|
||||
{"_element_to_bson", _cbson_element_to_bson, METH_VARARGS,
|
||||
"convert a key and value to its bson representation."},
|
||||
{"_dict_to_bson", _cbson_dict_to_bson, METH_O,
|
||||
"convert a dictionary to a string containing it's BSON representation."},
|
||||
{NULL, NULL, 0, NULL}
|
||||
|
||||
@ -289,8 +289,6 @@ def _document_to_dict(data):
|
||||
|
||||
def _shuffle_oid(data):
|
||||
return data[7::-1] + data[:7:-1]
|
||||
if _use_c:
|
||||
_shuffle_oid = _cbson._shuffle_oid
|
||||
|
||||
_RE_TYPE = type(_valid_array_name)
|
||||
def _element_to_bson(key, value):
|
||||
@ -352,14 +350,6 @@ def _element_to_bson(key, value):
|
||||
ns = _make_c_string(value.collection())
|
||||
return "\x0C" + name + struct.pack("<i", len(ns)) + ns + _shuffle_oid(str(value.id()))
|
||||
raise InvalidDocument("cannot convert value of type %s to bson" % type(value))
|
||||
if _use_c:
|
||||
_py_element_to_bson = _element_to_bson
|
||||
_c_element_to_bson = _cbson._element_to_bson
|
||||
def _element_to_bson(name, value):
|
||||
try:
|
||||
return _c_element_to_bson(name, value)
|
||||
except _cbson.error:
|
||||
return _py_element_to_bson(name, value)
|
||||
|
||||
def _dict_to_bson(dict):
|
||||
try:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user