chiark / gitweb /
systemd-python: add _Reader.closed attribute
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 15 Mar 2013 22:10:51 +0000 (18:10 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 20 Mar 2013 01:50:42 +0000 (21:50 -0400)
This should make the file interface of _Reader complete.

TODO
src/python-systemd/_reader.c

diff --git a/TODO b/TODO
index c73e8dc..715dd9d 100644 (file)
--- a/TODO
+++ b/TODO
@@ -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
index 6759555..67358e3 100644 (file)
@@ -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 */