Export rpmtsEmpty() to python as ts.clear()
authorPanu Matilainen <Panu Matilainen pmatilai@redhat.com>
Thu, 25 Aug 2011 09:02:48 +0000 (12:02 +0300)
committerPanu Matilainen <Panu Matilainen pmatilai@redhat.com>
Thu, 25 Aug 2011 09:21:16 +0000 (12:21 +0300)
- Why the heck hasn't this been exported before, duh?
- Method name clear() chosen as this appears to be emerging as a
  standard of sorts for this kind of operation: dictionaries and
  sets have it and list will get it in some python 3.x version.
  Additionally foo.empty() could easily be mistaken for "test whether
  container foo is empty or not" (especially those with c++ background...)

python/rpmts-py.c

index 0a55417..854d3a1 100644 (file)
@@ -279,6 +279,14 @@ rpmts_Clean(rpmtsObject * s)
 }
 
 static PyObject *
+rpmts_Clear(rpmtsObject * s)
+{
+    rpmtsEmpty(s->ts);
+
+    Py_RETURN_NONE;
+}
+
+static PyObject *
 rpmts_OpenDB(rpmtsObject * s)
 {
     int dbmode;
@@ -677,6 +685,9 @@ static struct PyMethodDef rpmts_methods[] = {
   Note: The callback may not be None.\n" },
  {"clean",     (PyCFunction) rpmts_Clean,      METH_NOARGS,
        NULL },
+ {"clear",     (PyCFunction) rpmts_Clear,      METH_NOARGS,
+"ts.clear() -> None\n\
+Remove all elements from the transaction set\n" },
  {"openDB",    (PyCFunction) rpmts_OpenDB,     METH_NOARGS,
 "ts.openDB() -> None\n\
 - Open the default transaction rpmdb.\n\