summaryrefslogtreecommitdiff
path: root/python/rpm/__init__.py
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2009-09-28 16:07:09 +0300
committerPanu Matilainen <pmatilai@redhat.com>2009-09-28 16:07:09 +0300
commit07710f3033b277ccb46decd84f994e88d5e6869a (patch)
treef964c7790b26c5a02e459017073a250893a2835d /python/rpm/__init__.py
parentf0e9245660100d3ce41692889899844f42feb7a4 (diff)
downloadlibrpm-tizen-07710f3033b277ccb46decd84f994e88d5e6869a.tar.gz
librpm-tizen-07710f3033b277ccb46decd84f994e88d5e6869a.tar.bz2
librpm-tizen-07710f3033b277ccb46decd84f994e88d5e6869a.zip
Implement rpm.readHeaderListFromFD() in python instead of C
Diffstat (limited to 'python/rpm/__init__.py')
-rw-r--r--python/rpm/__init__.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/python/rpm/__init__.py b/python/rpm/__init__.py
index bbce2368b..f59dffa23 100644
--- a/python/rpm/__init__.py
+++ b/python/rpm/__init__.py
@@ -17,6 +17,24 @@ def headerLoad(*args, **kwds):
warnings.warn("Use rpm.hdr() instead.", DeprecationWarning, stacklevel=2)
return hdr(*args, **kwds)
+def readHeaderListFromFD(fd, retrofit = True):
+ if hasattr(fd, "fileno"):
+ fdno = fd.fileno()
+ else:
+ fdno = fd
+
+ hlist = []
+ while 1:
+ try:
+ h = hdr(fdno)
+ if retrofit:
+ h.convert(HEADERCONV_RETROFIT_V3)
+ hlist.append(h)
+ except _rpm.error:
+ break
+
+ return hlist
+
def readHeaderListFromFile(path):
f = open(path)
hlist = readHeaderListFromFD(f)