From d99b0256c9f48132c5c9838afded1a6084d3fd2a Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Fri, 29 Dec 2017 11:27:30 +0000 Subject: [PATCH] python: Expose database description and vendor Signed-off-by: Michael Tremer --- src/python/database.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/python/database.c b/src/python/database.c index 0e3ddea..6d2a541 100644 --- a/src/python/database.c +++ b/src/python/database.c @@ -68,10 +68,40 @@ static int Database_init(DatabaseObject* self, PyObject* args, PyObject* kwargs) return 0; } +static PyObject* Database_get_description(DatabaseObject* self) { + const char* description = loc_database_get_description(self->db); + + return PyUnicode_FromString(description); +} + +static PyObject* Database_get_vendor(DatabaseObject* self) { + const char* vendor = loc_database_get_vendor(self->db); + + return PyUnicode_FromString(vendor); +} + static struct PyMethodDef Database_methods[] = { { NULL }, }; +static struct PyGetSetDef Database_getsetters[] = { + { + "description", + (getter)Database_get_description, + NULL, + NULL, + NULL, + }, + { + "vendor", + (getter)Database_get_vendor, + NULL, + NULL, + NULL + }, + { NULL }, +}; + PyTypeObject DatabaseType = { PyVarObject_HEAD_INIT(NULL, 0) tp_name: "location.Database", @@ -82,4 +112,5 @@ PyTypeObject DatabaseType = { tp_init: (initproc)Database_init, tp_doc: "Database object", tp_methods: Database_methods, + tp_getset: Database_getsetters, }; -- 2.39.2