From: Michael Tremer Date: Fri, 29 Dec 2017 11:27:30 +0000 (+0000) Subject: python: Expose database description and vendor X-Git-Tag: 0.9.0~156 X-Git-Url: http://git.ipfire.org/?p=people%2Fms%2Flibloc.git;a=commitdiff_plain;h=d99b0256c9f48132c5c9838afded1a6084d3fd2a python: Expose database description and vendor Signed-off-by: Michael Tremer --- 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, };