diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2013-03-15 18:10:51 -0400 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2013-03-19 21:50:42 -0400 |
commit | 6531dac67cc2e707e4a2b62f3ae11f7330f7c049 (patch) | |
tree | c6ff938a8dbb6884e21189529f0029fa711c5482 | |
parent | 52aeb63cffcdb3701cdc2ca41868208de2347318 (diff) |
systemd-python: add _Reader.closed attribute
This should make the file interface of _Reader complete.
-rw-r--r-- | TODO | 2 | ||||
-rw-r--r-- | src/python-systemd/_reader.c | 16 |
2 files changed, 14 insertions, 4 deletions
@@ -586,8 +586,6 @@ Features: - allow reading of only select fields in systemd.journal._reader.Reader - export sd_journal_test_cursor in systemd.journal._reader.Reader - export sd_journal_get_usage in systemd.journal._reader.Reader - - add systemd.journal._reader._Reader.closed attribute (it can - be just "return self->j != NULL") - figure out a simple way to wait for journal events in a way that works with ^C - add documentation to systemd.daemon diff --git a/src/python-systemd/_reader.c b/src/python-systemd/_reader.c index 6759555c12..67358e3061 100644 --- a/src/python-systemd/_reader.c +++ b/src/python-systemd/_reader.c @@ -666,12 +666,24 @@ static int Reader_set_data_threshold(Reader *self, PyObject *value, void *closur return set_error(r, NULL, NULL); } -static PyGetSetDef Reader_getseters[] = { +PyDoc_STRVAR(closed__doc__, + "True iff journal is closed"); +static PyObject* Reader_get_closed(Reader *self, void *closure) +{ + return PyBool_FromLong(self->j == NULL); +} + +static PyGetSetDef Reader_getsetters[] = { {(char*) "data_threshold", (getter) Reader_get_data_threshold, (setter) Reader_set_data_threshold, (char*) data_threshold__doc__, NULL}, + {(char*) "closed", + (getter) Reader_get_closed, + NULL, + (char*) closed__doc__, + NULL}, {NULL} }; @@ -727,7 +739,7 @@ static PyTypeObject ReaderType = { Reader_iternext, /* tp_iternext */ Reader_methods, /* tp_methods */ 0, /* tp_members */ - Reader_getseters, /* tp_getset */ + Reader_getsetters, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ |