]> git.ipfire.org Git - location/libloc.git/commitdiff
python: Expose database description and vendor
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 29 Dec 2017 11:27:30 +0000 (11:27 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 29 Dec 2017 11:27:30 +0000 (11:27 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/python/database.c

index 0e3ddea8c22b5059e4de74ec9bd6c28566e2448f..6d2a54193b818ff862f5b4e0cccbc474488dcb65 100644 (file)
@@ -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,
 };