mirror of
https://github.com/samba-team/samba.git
synced 2025-12-23 00:23:53 +03:00
r26586: Rename fetch to get for consistency with the Python dictionary interface.
This commit is contained in:
committed by
Stefan Metzmacher
parent
231ec0777b
commit
fadab7c60b
@@ -44,9 +44,9 @@ class SimpleTdbTests(TestCase):
|
||||
|
||||
def test_store(self):
|
||||
self.tdb.store("bar", "bla")
|
||||
self.assertEquals("bla", self.tdb.fetch("bar"))
|
||||
self.assertEquals("bla", self.tdb.get("bar"))
|
||||
|
||||
def test_fetch(self):
|
||||
def test_getitem(self):
|
||||
self.tdb["bar"] = "foo"
|
||||
self.tdb.reopen()
|
||||
self.assertEquals("foo", self.tdb["bar"])
|
||||
|
||||
@@ -158,6 +158,7 @@ typedef struct tdb_context {
|
||||
int close();
|
||||
int append(TDB_DATA key, TDB_DATA new_dbuf);
|
||||
const char *errorstr();
|
||||
%rename(get) fetch;
|
||||
TDB_DATA fetch(TDB_DATA key);
|
||||
int delete(TDB_DATA key);
|
||||
int store(TDB_DATA key, TDB_DATA dbuf, int flag);
|
||||
@@ -186,7 +187,7 @@ typedef struct tdb_context {
|
||||
|
||||
# Random access to keys, values
|
||||
def __getitem__(self, key):
|
||||
result = self.fetch(key)
|
||||
result = self.get(key)
|
||||
if result is None:
|
||||
raise KeyError, '%s: %s' % (key, self.errorstr())
|
||||
return result
|
||||
@@ -207,14 +208,14 @@ typedef struct tdb_context {
|
||||
return self.exists(key) != 0
|
||||
|
||||
def fetch_uint32(self, key):
|
||||
data = self.fetch(key)
|
||||
data = self.get(key)
|
||||
if data is None:
|
||||
return None
|
||||
import struct
|
||||
return struct.unpack("<L", data)[0]
|
||||
|
||||
def fetch_int32(self, key):
|
||||
data = self.fetch(key)
|
||||
data = self.get(key)
|
||||
if data is None:
|
||||
return None
|
||||
import struct
|
||||
|
||||
@@ -88,7 +88,7 @@ class tdb(object):
|
||||
|
||||
|
||||
def __getitem__(self, key):
|
||||
result = self.fetch(key)
|
||||
result = self.get(key)
|
||||
if result is None:
|
||||
raise KeyError, '%s: %s' % (key, self.errorstr())
|
||||
return result
|
||||
@@ -109,14 +109,14 @@ class tdb(object):
|
||||
return self.exists(key) != 0
|
||||
|
||||
def fetch_uint32(self, key):
|
||||
data = self.fetch(key)
|
||||
data = self.get(key)
|
||||
if data is None:
|
||||
return None
|
||||
import struct
|
||||
return struct.unpack("<L", data)[0]
|
||||
|
||||
def fetch_int32(self, key):
|
||||
data = self.fetch(key)
|
||||
data = self.get(key)
|
||||
if data is None:
|
||||
return None
|
||||
import struct
|
||||
@@ -172,7 +172,7 @@ tdb.error = new_instancemethod(_tdb.tdb_error,None,tdb)
|
||||
tdb.close = new_instancemethod(_tdb.tdb_close,None,tdb)
|
||||
tdb.append = new_instancemethod(_tdb.tdb_append,None,tdb)
|
||||
tdb.errorstr = new_instancemethod(_tdb.tdb_errorstr,None,tdb)
|
||||
tdb.fetch = new_instancemethod(_tdb.tdb_fetch,None,tdb)
|
||||
tdb.get = new_instancemethod(_tdb.tdb_get,None,tdb)
|
||||
tdb.delete = new_instancemethod(_tdb.tdb_delete,None,tdb)
|
||||
tdb.store = new_instancemethod(_tdb.tdb_store,None,tdb)
|
||||
tdb.exists = new_instancemethod(_tdb.tdb_exists,None,tdb)
|
||||
|
||||
@@ -3014,7 +3014,7 @@ fail:
|
||||
}
|
||||
|
||||
|
||||
SWIGINTERN PyObject *_wrap_tdb_fetch(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
|
||||
SWIGINTERN PyObject *_wrap_tdb_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
|
||||
PyObject *resultobj = 0;
|
||||
tdb *arg1 = (tdb *) 0 ;
|
||||
TDB_DATA arg2 ;
|
||||
@@ -3027,10 +3027,10 @@ SWIGINTERN PyObject *_wrap_tdb_fetch(PyObject *SWIGUNUSEDPARM(self), PyObject *a
|
||||
(char *) "self",(char *) "key", NULL
|
||||
};
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:tdb_fetch",kwnames,&obj0,&obj1)) SWIG_fail;
|
||||
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:tdb_get",kwnames,&obj0,&obj1)) SWIG_fail;
|
||||
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
|
||||
if (!SWIG_IsOK(res1)) {
|
||||
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_fetch" "', argument " "1"" of type '" "tdb *""'");
|
||||
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_get" "', argument " "1"" of type '" "tdb *""'");
|
||||
}
|
||||
arg1 = (tdb *)(argp1);
|
||||
if (obj1 == Py_None) {
|
||||
@@ -3607,7 +3607,7 @@ static PyMethodDef SwigMethods[] = {
|
||||
{ (char *)"tdb_close", (PyCFunction)_wrap_tdb_close, METH_O, NULL},
|
||||
{ (char *)"tdb_append", (PyCFunction) _wrap_tdb_append, METH_VARARGS | METH_KEYWORDS, NULL},
|
||||
{ (char *)"tdb_errorstr", (PyCFunction)_wrap_tdb_errorstr, METH_O, NULL},
|
||||
{ (char *)"tdb_fetch", (PyCFunction) _wrap_tdb_fetch, METH_VARARGS | METH_KEYWORDS, NULL},
|
||||
{ (char *)"tdb_get", (PyCFunction) _wrap_tdb_get, METH_VARARGS | METH_KEYWORDS, NULL},
|
||||
{ (char *)"tdb_delete", (PyCFunction) _wrap_tdb_delete, METH_VARARGS | METH_KEYWORDS, NULL},
|
||||
{ (char *)"tdb_store", (PyCFunction) _wrap_tdb_store, METH_VARARGS | METH_KEYWORDS, NULL},
|
||||
{ (char *)"tdb_exists", (PyCFunction) _wrap_tdb_exists, METH_VARARGS | METH_KEYWORDS, NULL},
|
||||
|
||||
Reference in New Issue
Block a user