add compress/uncompress filelist
authormsw <devnull@localhost>
Fri, 11 Feb 2000 20:29:22 +0000 (20:29 +0000)
committermsw <devnull@localhost>
Fri, 11 Feb 2000 20:29:22 +0000 (20:29 +0000)
CVS patchset: 3552
CVS date: 2000/02/11 20:29:22

python/rpmmodule.c
python/testhdr [new file with mode: 0755]

index 888adc9..ba24c64 100644 (file)
@@ -9,6 +9,7 @@
 
 #include "Python.h"
 #include "rpmlib.h"
+#include "misc.h"
 #include "rpmmacro.h"
 #include "upgrade.h"
 
@@ -39,6 +40,8 @@ static PyObject * hdrSubscript(hdrObject * s, PyObject * item);
 static PyObject * hdrKeyList(hdrObject * s, PyObject * args);
 static PyObject * hdrUnload(hdrObject * s, PyObject * args);
 static PyObject * hdrVerifyFile(hdrObject * s, PyObject * args);
+static PyObject * hdrCompressFilelist(hdrObject * s, PyObject * args);
+static PyObject * hdrExpandFilelist(hdrObject * s, PyObject * args);
 
 void initrpm(void);
 static PyObject * doAddMacro(PyObject * self, PyObject * args);
@@ -205,6 +208,8 @@ static struct PyMethodDef hdrMethods[] = {
        {"keys",        (PyCFunction) hdrKeyList,       1 },
        {"unload",      (PyCFunction) hdrUnload,        1 },
        {"verifyFile",  (PyCFunction) hdrVerifyFile,    1 },
+       {"expandFilelist",      (PyCFunction) hdrExpandFilelist,        1 },
+       {"compressFilelist",    (PyCFunction) hdrCompressFilelist,      1 },
        {NULL,          NULL}           /* sentinel */
 };
 
@@ -1262,6 +1267,20 @@ static PyObject * hdrVerifyFile(hdrObject * s, PyObject * args) {
     return list;
 }
 
+static PyObject * hdrCompressFilelist(hdrObject * s, PyObject * args) {
+    compressFilelist (s->h);
+
+    Py_INCREF(Py_None);
+    return Py_None;
+}
+
+static PyObject * hdrExpandFilelist(hdrObject * s, PyObject * args) {
+    expandFilelist (s->h);
+
+    Py_INCREF(Py_None);
+    return Py_None;
+}
+
 static PyObject * rpmtransCreate(PyObject * self, PyObject * args) {
     rpmtransObject * o;
     rpmdbObject * db = NULL;
diff --git a/python/testhdr b/python/testhdr
new file mode 100755 (executable)
index 0000000..d209bee
--- /dev/null
@@ -0,0 +1,31 @@
+#!/usr/bin/python
+
+import rpm
+
+def printlist(h, tag):
+    print "####### %s tag contains:" % tag
+    i = 0
+    list = h[tag]
+    if not list:
+        print "NO SUCH TAG"
+        return
+    
+    for file in list:
+        print file
+        i = i + 1
+    print "******** %d files" % i
+    
+
+db = rpm.opendb(0)
+rc = db.findbyname('redhat-release')
+h = db[rc[0]]
+printlist (h, 'filenames')
+printlist (h, 'oldfilenames')
+h.expandFilelist()
+print "-------------- expand --------------------"
+printlist (h, 'oldfilenames')
+printlist (h, 'filenames')
+print "-------------- compress --------------------"
+h.compressFilelist()
+printlist (h, 'oldfilenames')
+printlist (h, 'filenames')