From: Michael Tremer Date: Fri, 29 Dec 2017 19:52:17 +0000 (+0000) Subject: python: Implement setting description to the writer X-Git-Tag: 0.9.0~139 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9224f7bac5c8a07075ca9e58bf6f1186b1985202;p=people%2Fms%2Flibloc.git python: Implement setting description to the writer Signed-off-by: Michael Tremer --- diff --git a/src/python/writer.c b/src/python/writer.c index 6d4ea68..f7bcb62 100644 --- a/src/python/writer.c +++ b/src/python/writer.c @@ -63,6 +63,24 @@ static int Writer_set_vendor(WriterObject* self, PyObject* value) { return 0; } +static PyObject* Writer_get_description(WriterObject* self) { + const char* description = loc_writer_get_description(self->writer); + + return PyUnicode_FromString(description); +} + +static int Writer_set_description(WriterObject* self, PyObject* value) { + const char* description = PyUnicode_AsUTF8(value); + + int r = loc_writer_set_description(self->writer, description); + if (r) { + PyErr_Format(PyExc_ValueError, "Could not set description: %s", description); + return r; + } + + return 0; +} + static PyObject* Writer_add_as(WriterObject* self, PyObject* args) { struct loc_as* as; uint32_t number = 0; @@ -122,6 +140,13 @@ static struct PyMethodDef Writer_methods[] = { }; static struct PyGetSetDef Writer_getsetters[] = { + { + "description", + (getter)Writer_get_description, + (setter)Writer_set_description, + NULL, + NULL, + }, { "vendor", (getter)Writer_get_vendor,