search for: callback_has_parameter

Displaying 5 results from an estimated 5 matches for "callback_has_parameter".

2019 Nov 25
6
[nbdkit PATCH 0/5] Counterproposal for python v2 interfaces
As mentioned in my reviews, I wonder if we should make our python callbacks look a bit more Pythonic by having kwargs added for each new flag that we want to expose. The idea was first floated here: https://www.redhat.com/archives/libguestfs/2018-April/msg00108.html Note that with my proposal, there is no need for a python script to expose a global API_VERSION variable; new flags are added
2018 Apr 06
1
[nbdkit PATCH] python: Let zero's may_trim parameter be optional
...= 0; + PyObject *elt; + + if (!list) + return 0; + while ((elt = PyList_GetItem(list, i++))) { + char *str = PyString_AsString(elt); + if (str && !strcmp(str, name)) + return 1; + } + return 0; +} + +/* Does a callback support the given keyword parameter? */ +static int +callback_has_parameter (PyObject *fn, const char *name) +{ + int r = 0; + PyObject *inspect, *pname, *spec, *args; + + assert (script != NULL); + assert (module != NULL); + + pname = PyString_FromString ("inspect"); + if (!pname) + return -1; + inspect = PyImport_Import (pname); + Py_DECREF (pname);...
2018 Apr 11
0
[nbdkit PATCH v2 4/5] python: Expose FUA support
..._size' or 'pread' is not defined by this Python script. nbdkit requires these callbacks.", script); return -1; } + + /* One-time setup to learn which callbacks have a fua parameter */ + if (callback_defined ("pwrite", &fn)) { + pwrite_has_fua = callback_has_parameter (fn, "fua"); + Py_DECREF (fn); + if (pwrite_has_fua < 0) { + check_python_failure ("config"); + return -1; + } + } + if (callback_defined ("zero", &fn)) { + zero_has_fua = callback_has_parameter (fn, "fua"); +...
2018 Apr 11
0
[nbdkit PATCH v2 1/5] python: Let zero's may_trim parameter be optional
...0; + PyObject *elt; + + if (!list) + return 0; + while ((elt = PyList_GetItem (list, i++))) { + char *str = PyString_AsString (elt); + if (str && !strcmp (str, name)) + return 1; + } + return 0; +} + +/* Does a callback support the given keyword parameter? */ +static int +callback_has_parameter (PyObject *fn, const char *name) +{ + int r = 0; + PyObject *inspect, *pname, *spec, *args; + + assert (script != NULL); + assert (module != NULL); + +#ifdef HAVE_PYSTRING_FROMSTRING + pname = PyString_FromString ("inspect"); +#else + pname = PyUnicode_FromString ("inspect&quot...
2018 Apr 11
10
[nbdkit PATCH v2 0/5] FUA support in Python scripts
First out of our four language bindings to add FUA support (for reference, I added 'zero' support for python, perl, and ruby back in 1.1.13, then Rich had to add it for ocaml in 1.1.20). I tested this heavily under python 2, but for now only compile tested under python 3; I plan to do further testing there and make any tweaks if necessary. I wrote patch 5 early on, but then realized I