Python module: rename .py files to .in
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Fri, 18 May 2012 16:03:36 +0000 (19:03 +0300)
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Mon, 9 Jun 2014 09:26:41 +0000 (12:26 +0300)
In order to make them modifiable by autotools.

configure.ac
python/rpm/__init__.py [deleted file]
python/rpm/__init__.py.in [new file with mode: 0644]
python/rpm/transaction.py [deleted file]
python/rpm/transaction.py.in [new file with mode: 0644]

index e97f727f06d50d5d99dd9e5c6f87b178e45cb0a8..644683adc6a2ff4549ec74d769b9386ffc1e9cf7 100644 (file)
@@ -906,6 +906,8 @@ AC_CONFIG_FILES([Makefile
        misc/Makefile 
        doc/Makefile
        python/Makefile
+       python/rpm/__init__.py
+       python/rpm/transaction.py
        luaext/Makefile
        tests/Makefile
        plugins/Makefile
diff --git a/python/rpm/__init__.py b/python/rpm/__init__.py
deleted file mode 100644 (file)
index d868d19..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-r"""RPM Module
-
-This module enables you to manipulate rpms and the rpm database.
-
-"""
-
-import warnings
-import os
-from rpm._rpm import *
-from rpm.transaction import *
-import rpm._rpm as _rpm
-_RPMVSF_NODIGESTS = _rpm._RPMVSF_NODIGESTS
-_RPMVSF_NOHEADER = _rpm._RPMVSF_NOHEADER
-_RPMVSF_NOPAYLOAD = _rpm._RPMVSF_NOPAYLOAD
-_RPMVSF_NOSIGNATURES = _rpm._RPMVSF_NOSIGNATURES
-
-__version__ = _rpm.__version__
-__version_info__ = tuple(__version__.split('.'))
-
-# try to import build bits but dont require it
-try:
-    from rpm._rpmb import *
-except ImportError:
-    pass
-
-# try to import signing bits but dont require it
-try:
-    from rpm._rpms import *
-except ImportError:
-    pass
-
-# backwards compatibility + give the same class both ways
-ts = TransactionSet
-
-def headerLoad(*args, **kwds):
-    warnings.warn("Use rpm.hdr() instead.", DeprecationWarning, stacklevel=2)
-    return hdr(*args, **kwds)
-
-def _doHeaderListFromFD(rpm_fd, retrofit):
-    hlist = []
-    while 1:
-        try:
-            h = hdr(rpm_fd)
-            if retrofit:
-                h.convert(HEADERCONV_RETROFIT_V3)
-            hlist.append(h)
-        except _rpm.error:
-            break
-
-    return hlist
-
-def readHeaderListFromFD(file_desc, retrofit = True):
-    if not isinstance(file_desc, fd):
-        file_desc = fd(file_desc)
-    return _doHeaderListFromFD(file_desc, retrofit)
-        
-def readHeaderListFromFile(path, retrofit = True):
-    f = fd(path)
-    hlist = _doHeaderListFromFD(f, retrofit)
-    f.close()
-    return hlist
-    
-def readHeaderFromFD(file_desc):
-    if not isinstance(file_desc, fd):
-        file_desc = fd(file_desc)
-    try:
-        offset = file_desc.tell()
-        h = hdr(file_desc)
-    except (_rpm.error, IOError):
-        offset = None
-        h = None
-
-    return (h, offset)
-
-def signalsCaught(siglist):
-    caught = []
-    for sig in siglist:
-        if signalCaught(sig):
-            caught.append(sig)
-
-    return caught
-
-def dsSingle(TagN, N, EVR = "", Flags = RPMSENSE_ANY):
-    return ds((N, EVR, Flags), TagN)
diff --git a/python/rpm/__init__.py.in b/python/rpm/__init__.py.in
new file mode 100644 (file)
index 0000000..d868d19
--- /dev/null
@@ -0,0 +1,84 @@
+r"""RPM Module
+
+This module enables you to manipulate rpms and the rpm database.
+
+"""
+
+import warnings
+import os
+from rpm._rpm import *
+from rpm.transaction import *
+import rpm._rpm as _rpm
+_RPMVSF_NODIGESTS = _rpm._RPMVSF_NODIGESTS
+_RPMVSF_NOHEADER = _rpm._RPMVSF_NOHEADER
+_RPMVSF_NOPAYLOAD = _rpm._RPMVSF_NOPAYLOAD
+_RPMVSF_NOSIGNATURES = _rpm._RPMVSF_NOSIGNATURES
+
+__version__ = _rpm.__version__
+__version_info__ = tuple(__version__.split('.'))
+
+# try to import build bits but dont require it
+try:
+    from rpm._rpmb import *
+except ImportError:
+    pass
+
+# try to import signing bits but dont require it
+try:
+    from rpm._rpms import *
+except ImportError:
+    pass
+
+# backwards compatibility + give the same class both ways
+ts = TransactionSet
+
+def headerLoad(*args, **kwds):
+    warnings.warn("Use rpm.hdr() instead.", DeprecationWarning, stacklevel=2)
+    return hdr(*args, **kwds)
+
+def _doHeaderListFromFD(rpm_fd, retrofit):
+    hlist = []
+    while 1:
+        try:
+            h = hdr(rpm_fd)
+            if retrofit:
+                h.convert(HEADERCONV_RETROFIT_V3)
+            hlist.append(h)
+        except _rpm.error:
+            break
+
+    return hlist
+
+def readHeaderListFromFD(file_desc, retrofit = True):
+    if not isinstance(file_desc, fd):
+        file_desc = fd(file_desc)
+    return _doHeaderListFromFD(file_desc, retrofit)
+        
+def readHeaderListFromFile(path, retrofit = True):
+    f = fd(path)
+    hlist = _doHeaderListFromFD(f, retrofit)
+    f.close()
+    return hlist
+    
+def readHeaderFromFD(file_desc):
+    if not isinstance(file_desc, fd):
+        file_desc = fd(file_desc)
+    try:
+        offset = file_desc.tell()
+        h = hdr(file_desc)
+    except (_rpm.error, IOError):
+        offset = None
+        h = None
+
+    return (h, offset)
+
+def signalsCaught(siglist):
+    caught = []
+    for sig in siglist:
+        if signalCaught(sig):
+            caught.append(sig)
+
+    return caught
+
+def dsSingle(TagN, N, EVR = "", Flags = RPMSENSE_ANY):
+    return ds((N, EVR, Flags), TagN)
diff --git a/python/rpm/transaction.py b/python/rpm/transaction.py
deleted file mode 100644 (file)
index 73e4b3c..0000000
+++ /dev/null
@@ -1,156 +0,0 @@
-#!/usr/bin/python
-
-import rpm
-from rpm._rpm import ts as TransactionSetCore
-
-# TODO: migrate relevant documentation from C-side
-class TransactionSet(TransactionSetCore):
-    _probFilter = 0
-
-    def _wrapSetGet(self, attr, val):
-        oval = getattr(self, attr)
-        setattr(self, attr, val)
-        return oval
-        
-    def setVSFlags(self, flags):
-        return self._wrapSetGet('_vsflags', flags)
-
-    def getVSFlags(self):
-        return self._vsflags
-
-    def setColor(self, color):
-        return self._wrapSetGet('_color', color)
-
-    def setPrefColor(self, color):
-        return self._wrapSetGet('_prefcolor', color)
-
-    def setFlags(self, flags):
-        return self._wrapSetGet('_flags', flags)
-
-    def setProbFilter(self, ignoreSet):
-        return self._wrapSetGet('_probFilter', ignoreSet)
-
-    def parseSpec(self, specfile):
-        import _rpmb
-        return _rpmb.spec(specfile)
-
-    def getKeys(self):
-        keys = []
-        for te in self:
-            keys.append(te.Key())
-        # Backwards compatibility goo - WTH does this return a *tuple* ?!
-        if not keys:
-            return None
-        else:
-            return tuple(keys)
-
-    def addInstall(self, item, key, how="u"):
-        if isinstance(item, basestring):
-            f = file(item)
-            header = self.hdrFromFdno(f)
-            f.close()
-        elif isinstance(item, file):
-            header = self.hdrFromFdno(item)
-        else:
-            header = item
-
-        if not how in ['u', 'i']:
-            raise ValueError('how argument must be "u" or "i"')
-        upgrade = (how == "u")
-
-        if not TransactionSetCore.addInstall(self, header, key, upgrade):
-            raise rpm.error("adding package to transaction failed")
-
-    def addErase(self, item):
-        hdrs = []
-        if isinstance(item, rpm.hdr):
-            hdrs = [item]
-        elif isinstance(item, rpm.mi):
-            hdrs = item
-        elif isinstance(item, int):
-            hdrs = self.dbMatch(rpm.RPMDBI_PACKAGES, item)
-        elif isinstance(item, basestring):
-            hdrs = self.dbMatch(rpm.RPMDBI_LABEL, item)
-        else:
-            raise TypeError("invalid type %s" % type(item))
-
-        for h in hdrs:
-            if not TransactionSetCore.addErase(self, h):
-                raise rpm.error("package not installed")
-
-        # garbage collection should take care but just in case...
-        if isinstance(hdrs, rpm.mi):
-            del hdrs
-
-    def run(self, callback, data):
-        rc = TransactionSetCore.run(self, callback, data, self._probFilter)
-
-        # crazy backwards compatibility goo: None for ok, list of problems
-        # if transaction didnt complete and empty list if it completed
-        # with errors
-        if rc == 0:
-            return None
-
-        res = []
-        if rc > 0:
-            for prob in self.problems():
-                item = ("%s" % prob, (prob.type, prob._str, prob._num))
-                res.append(item)
-        return res
-
-    def check(self, *args, **kwds):
-        TransactionSetCore.check(self, *args, **kwds)
-
-        # compatibility: munge problem strings into dependency tuples of doom
-        res = []
-        for p in self.problems():
-            # is it anything we need to care about?
-            if p.type == rpm.RPMPROB_CONFLICT:
-                sense = rpm.RPMDEP_SENSE_CONFLICTS
-            elif p.type == rpm.RPMPROB_REQUIRES:
-                sense = rpm.RPMDEP_SENSE_REQUIRES
-            else:
-                continue
-
-            # strip arch, split to name, version, release
-            nevr = p.altNEVR.rsplit('.', 1)[0]
-            n, v, r = nevr.rsplit('-', 2)
-
-            # extract the dependency information
-            needs = p._str.split()
-            needname = needs[0]
-            needflags = rpm.RPMSENSE_ANY
-            if len(needs) == 3:
-                needop = needs[1]
-                if needop.find('<') >= 0: needflags |= rpm.RPMSENSE_LESS
-                if needop.find('=') >= 0: needflags |= rpm.RPMSENSE_EQUAL
-                if needop.find('>') >= 0: needflags |= rpm.RPMSENSE_GREATER
-                needver = needs[2]
-            else:
-                needver = ""
-
-            res.append(((n, v, r),(needname,needver),needflags,sense,p.key))
-
-        return res
-
-    def hdrCheck(self, blob):
-        res, msg = TransactionSetCore.hdrCheck(self, blob)
-        # generate backwards compatibly broken exceptions
-        if res == rpm.RPMRC_NOKEY:
-            raise rpm.error("public key not available")
-        elif res == rpm.RPMRC_NOTTRUSTED:
-            raise rpm.error("public key not trusted")
-        elif res != rpm.RPMRC_OK:
-            raise rpm.error(msg)
-
-    def hdrFromFdno(self, fd):
-        res, h = TransactionSetCore.hdrFromFdno(self, fd)
-        # generate backwards compatibly broken exceptions
-        if res == rpm.RPMRC_NOKEY:
-            raise rpm.error("public key not available")
-        elif res == rpm.RPMRC_NOTTRUSTED:
-            raise rpm.error("public key not trusted")
-        elif res != rpm.RPMRC_OK:
-            raise rpm.error("error reading package header")
-
-        return h
diff --git a/python/rpm/transaction.py.in b/python/rpm/transaction.py.in
new file mode 100644 (file)
index 0000000..73e4b3c
--- /dev/null
@@ -0,0 +1,156 @@
+#!/usr/bin/python
+
+import rpm
+from rpm._rpm import ts as TransactionSetCore
+
+# TODO: migrate relevant documentation from C-side
+class TransactionSet(TransactionSetCore):
+    _probFilter = 0
+
+    def _wrapSetGet(self, attr, val):
+        oval = getattr(self, attr)
+        setattr(self, attr, val)
+        return oval
+        
+    def setVSFlags(self, flags):
+        return self._wrapSetGet('_vsflags', flags)
+
+    def getVSFlags(self):
+        return self._vsflags
+
+    def setColor(self, color):
+        return self._wrapSetGet('_color', color)
+
+    def setPrefColor(self, color):
+        return self._wrapSetGet('_prefcolor', color)
+
+    def setFlags(self, flags):
+        return self._wrapSetGet('_flags', flags)
+
+    def setProbFilter(self, ignoreSet):
+        return self._wrapSetGet('_probFilter', ignoreSet)
+
+    def parseSpec(self, specfile):
+        import _rpmb
+        return _rpmb.spec(specfile)
+
+    def getKeys(self):
+        keys = []
+        for te in self:
+            keys.append(te.Key())
+        # Backwards compatibility goo - WTH does this return a *tuple* ?!
+        if not keys:
+            return None
+        else:
+            return tuple(keys)
+
+    def addInstall(self, item, key, how="u"):
+        if isinstance(item, basestring):
+            f = file(item)
+            header = self.hdrFromFdno(f)
+            f.close()
+        elif isinstance(item, file):
+            header = self.hdrFromFdno(item)
+        else:
+            header = item
+
+        if not how in ['u', 'i']:
+            raise ValueError('how argument must be "u" or "i"')
+        upgrade = (how == "u")
+
+        if not TransactionSetCore.addInstall(self, header, key, upgrade):
+            raise rpm.error("adding package to transaction failed")
+
+    def addErase(self, item):
+        hdrs = []
+        if isinstance(item, rpm.hdr):
+            hdrs = [item]
+        elif isinstance(item, rpm.mi):
+            hdrs = item
+        elif isinstance(item, int):
+            hdrs = self.dbMatch(rpm.RPMDBI_PACKAGES, item)
+        elif isinstance(item, basestring):
+            hdrs = self.dbMatch(rpm.RPMDBI_LABEL, item)
+        else:
+            raise TypeError("invalid type %s" % type(item))
+
+        for h in hdrs:
+            if not TransactionSetCore.addErase(self, h):
+                raise rpm.error("package not installed")
+
+        # garbage collection should take care but just in case...
+        if isinstance(hdrs, rpm.mi):
+            del hdrs
+
+    def run(self, callback, data):
+        rc = TransactionSetCore.run(self, callback, data, self._probFilter)
+
+        # crazy backwards compatibility goo: None for ok, list of problems
+        # if transaction didnt complete and empty list if it completed
+        # with errors
+        if rc == 0:
+            return None
+
+        res = []
+        if rc > 0:
+            for prob in self.problems():
+                item = ("%s" % prob, (prob.type, prob._str, prob._num))
+                res.append(item)
+        return res
+
+    def check(self, *args, **kwds):
+        TransactionSetCore.check(self, *args, **kwds)
+
+        # compatibility: munge problem strings into dependency tuples of doom
+        res = []
+        for p in self.problems():
+            # is it anything we need to care about?
+            if p.type == rpm.RPMPROB_CONFLICT:
+                sense = rpm.RPMDEP_SENSE_CONFLICTS
+            elif p.type == rpm.RPMPROB_REQUIRES:
+                sense = rpm.RPMDEP_SENSE_REQUIRES
+            else:
+                continue
+
+            # strip arch, split to name, version, release
+            nevr = p.altNEVR.rsplit('.', 1)[0]
+            n, v, r = nevr.rsplit('-', 2)
+
+            # extract the dependency information
+            needs = p._str.split()
+            needname = needs[0]
+            needflags = rpm.RPMSENSE_ANY
+            if len(needs) == 3:
+                needop = needs[1]
+                if needop.find('<') >= 0: needflags |= rpm.RPMSENSE_LESS
+                if needop.find('=') >= 0: needflags |= rpm.RPMSENSE_EQUAL
+                if needop.find('>') >= 0: needflags |= rpm.RPMSENSE_GREATER
+                needver = needs[2]
+            else:
+                needver = ""
+
+            res.append(((n, v, r),(needname,needver),needflags,sense,p.key))
+
+        return res
+
+    def hdrCheck(self, blob):
+        res, msg = TransactionSetCore.hdrCheck(self, blob)
+        # generate backwards compatibly broken exceptions
+        if res == rpm.RPMRC_NOKEY:
+            raise rpm.error("public key not available")
+        elif res == rpm.RPMRC_NOTTRUSTED:
+            raise rpm.error("public key not trusted")
+        elif res != rpm.RPMRC_OK:
+            raise rpm.error(msg)
+
+    def hdrFromFdno(self, fd):
+        res, h = TransactionSetCore.hdrFromFdno(self, fd)
+        # generate backwards compatibly broken exceptions
+        if res == rpm.RPMRC_NOKEY:
+            raise rpm.error("public key not available")
+        elif res == rpm.RPMRC_NOTTRUSTED:
+            raise rpm.error("public key not trusted")
+        elif res != rpm.RPMRC_OK:
+            raise rpm.error("error reading package header")
+
+        return h