diff options
Diffstat (limited to 'lang/python/wiredtiger.i')
-rw-r--r-- | lang/python/wiredtiger.i | 49 |
1 files changed, 31 insertions, 18 deletions
diff --git a/lang/python/wiredtiger.i b/lang/python/wiredtiger.i index d35d7d5c456..c46fd6d24a6 100644 --- a/lang/python/wiredtiger.i +++ b/lang/python/wiredtiger.i @@ -358,12 +358,12 @@ retry: $action if (result != 0 && result != EBUSY) SWIG_ERROR_IF_NOT_SET(result); - else if (result == EBUSY) { + else if (result == EBUSY) { SWIG_PYTHON_THREAD_BEGIN_ALLOW; - __wt_sleep(0, 10000); + __wt_sleep(0, 10000); SWIG_PYTHON_THREAD_END_ALLOW; - goto retry; - } + goto retry; + } } %enddef @@ -745,8 +745,8 @@ typedef int int_void; } else { ret = $self->equals($self, other, &cmp); - if (ret == 0) - ret = cmp; + if (ret == 0) + ret = cmp; } return (ret); } @@ -842,12 +842,25 @@ typedef int int_void; self._iterable = IterableCursor(self) return self._iterable + def __delitem__(self, key): + '''Python convenience for removing''' + self.set_key(key) + if self.remove() != 0: + raise KeyError + def __getitem__(self, key): '''Python convenience for searching''' self.set_key(key) if self.search() != 0: raise KeyError return self.get_value() + + def __setitem__(self, key, value): + '''Python convenience for inserting''' + self.set_key(key) + self.set_value(value) + if self.insert() != 0: + raise KeyError %} }; @@ -870,17 +883,17 @@ typedef int int_void; %{ int diagnostic_build() { #ifdef HAVE_DIAGNOSTIC - return 1; + return 1; #else - return 0; + return 0; #endif } int verbose_build() { #ifdef HAVE_VERBOSE - return 1; + return 1; #else - return 0; + return 0; #endif } %} @@ -1127,8 +1140,8 @@ pythonAsyncCallback(WT_ASYNC_CALLBACK *cb, WT_ASYNC_OP *asyncop, int opret, int ret, t_ret; PY_CALLBACK *pcb; PyObject *arglist, *notify_method, *pyresult; - WT_ASYNC_OP_IMPL *op; - WT_SESSION_IMPL *session; + WT_ASYNC_OP_IMPL *op; + WT_SESSION_IMPL *session; /* * Ensure the global interpreter lock is held since we'll be @@ -1136,8 +1149,8 @@ pythonAsyncCallback(WT_ASYNC_CALLBACK *cb, WT_ASYNC_OP *asyncop, int opret, */ SWIG_PYTHON_THREAD_BEGIN_BLOCK; - op = (WT_ASYNC_OP_IMPL *)asyncop; - session = O2S(op); + op = (WT_ASYNC_OP_IMPL *)asyncop; + session = O2S(op); pcb = (PY_CALLBACK *)asyncop->c.lang_private; asyncop->c.lang_private = NULL; ret = 0; @@ -1172,10 +1185,10 @@ err: __wt_err(session, ret, "python async callback error"); } __wt_free(session, pcb); - if (ret == 0 && (opret == 0 || opret == WT_NOTFOUND)) - return (0); - else - return (1); + if (ret == 0 && (opret == 0 || opret == WT_NOTFOUND)) + return (0); + else + return (1); } static WT_ASYNC_CALLBACK pyApiAsyncCallback = { pythonAsyncCallback }; |