From f0e9245660100d3ce41692889899844f42feb7a4 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Mon, 28 Sep 2009 14:50:33 +0300 Subject: [PATCH] Implement rpmreadHeaderListFromFile() in python instead of C --- python/header-py.c | 23 ----------------------- python/rpm/__init__.py | 7 +++++++ python/rpmmodule.c | 2 -- 3 files changed, 7 insertions(+), 25 deletions(-) diff --git a/python/header-py.c b/python/header-py.c index 521f5b6..755252e 100644 --- a/python/header-py.c +++ b/python/header-py.c @@ -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. diff --git a/python/rpm/__init__.py b/python/rpm/__init__.py index e706025..bbce236 100644 --- a/python/rpm/__init__.py +++ b/python/rpm/__init__.py @@ -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 + diff --git a/python/rpmmodule.c b/python/rpmmodule.c index 3d61046..4328fd4 100644 --- a/python/rpmmodule.c +++ b/python/rpmmodule.c @@ -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 }, -- 2.7.4