Implement rpmreadHeaderListFromFile() in python instead of C
authorPanu Matilainen <pmatilai@redhat.com>
Mon, 28 Sep 2009 11:50:33 +0000 (14:50 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Mon, 28 Sep 2009 11:50:33 +0000 (14:50 +0300)
python/header-py.c
python/rpm/__init__.py
python/rpmmodule.c

index 521f5b6..755252e 100644 (file)
@@ -576,29 +576,6 @@ PyObject * rpmHeaderFromFD(PyObject * self, PyObject * args, PyObject * kwds)
     return list;
 }
 
-PyObject * rpmHeaderFromFile(PyObject * self, PyObject * args, PyObject *kwds)
-{
-    char * filespec;
-    FD_t fd;
-    PyObject * list;
-    char * kwlist[] = {"file", NULL};
-
-    if (!PyArg_ParseTupleAndKeywords(args, kwds, "s", kwlist, &filespec))
-       return NULL;
-
-    fd = Fopen(filespec, "r.fdio");
-
-    if (!fd) {
-       PyErr_SetFromErrno(pyrpmError);
-       return NULL;
-    }
-
-    list = rpmReadHeaders (fd);
-    Fclose(fd);
-
-    return list;
-}
-
 /**
  * This assumes the order of list matches the order of the new headers, and
  * throws an exception if that isn't true.
index e706025..bbce236 100644 (file)
@@ -16,3 +16,10 @@ _RPMVSF_NOSIGNATURES = _rpm._RPMVSF_NOSIGNATURES
 def headerLoad(*args, **kwds):
     warnings.warn("Use rpm.hdr() instead.", DeprecationWarning, stacklevel=2)
     return hdr(*args, **kwds)
+
+def readHeaderListFromFile(path):
+    f = open(path)
+    hlist = readHeaderListFromFD(f)
+    f.close()
+    return hlist
+    
index 3d61046..4328fd4 100644 (file)
@@ -158,8 +158,6 @@ static PyMethodDef rpmModuleMethods[] = {
        NULL },
     { "readHeaderListFromFD", (PyCFunction) rpmHeaderFromFD, METH_VARARGS|METH_KEYWORDS,
        NULL },
-    { "readHeaderListFromFile", (PyCFunction) rpmHeaderFromFile, METH_VARARGS|METH_KEYWORDS,
-       NULL },
     { "readHeaderFromFD", (PyCFunction) rpmSingleHeaderFromFD, METH_VARARGS|METH_KEYWORDS,
        NULL },