From: Bartosz Golaszewski Date: Tue, 15 May 2018 16:33:47 +0000 (+0200) Subject: bindings: python: provide Line.is_requested() X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=16e5a3ce56274a597b45c0440e3a9a9951b09d2f;p=qemu-gpiodev%2Flibgpiod.git bindings: python: provide Line.is_requested() Add a python wrapper around gpiod_line_is_requested(). Signed-off-by: Bartosz Golaszewski --- diff --git a/bindings/python/gpiodmodule.c b/bindings/python/gpiodmodule.c index 8e1f012..8f8ac28 100644 --- a/bindings/python/gpiodmodule.c +++ b/bindings/python/gpiodmodule.c @@ -344,6 +344,17 @@ static PyObject *gpiod_Line_request(gpiod_LineObject *self, return ret; } +PyDoc_STRVAR(gpiod_Line_is_requested_doc, +"Check if this user has ownership of this line."); + +static PyObject *gpiod_Line_is_requested(gpiod_LineObject *self) +{ + if (gpiod_line_is_requested(self->line)) + Py_RETURN_TRUE; + + Py_RETURN_FALSE; +} + PyDoc_STRVAR(gpiod_Line_get_value_doc, "Read the current value of this GPIO line."); @@ -566,6 +577,12 @@ static PyMethodDef gpiod_Line_methods[] = { .ml_flags = METH_VARARGS | METH_KEYWORDS, .ml_doc = gpiod_Line_request_doc, }, + { + .ml_name = "is_requested", + .ml_meth = (PyCFunction)gpiod_Line_is_requested, + .ml_flags = METH_NOARGS, + .ml_doc = gpiod_Line_is_requested_doc, + }, { .ml_name = "get_value", .ml_meth = (PyCFunction)gpiod_Line_get_value,