Bug#603043: "Python-debian module not available"
On Mi, 2010-11-10 at 16:50 +0100, Max Kellermann wrote:
> Package: python-apt
> Version: 0.7.98.1
>
> Tried to run apt.debfile.DebPackage.control_content, got the following
> exception:
>
> File "/usr/lib/python2.6/dist-packages/apt/debfile.py", line 555, in control_content
> raise Exception(_("Python-debian module not available"))
> Exception: Python-debian module not available
>
> The package python-debian is not installed. Is there a dependency missing?
Unless you need the higher level stuff, use apt_inst.DebFile instead, as
it's easier to use.
The following patch should fix it and I pushed it to the repository as
revision number 464.
=== modified file 'apt/debfile.py'
--- apt/debfile.py 2010-09-20 08:33:44 +0000
+++ apt/debfile.py 2010-11-10 16:32:22 +0000
@@ -531,7 +531,7 @@ class DebPackage(object):
return s
def _get_content(self, part, name, auto_decompress=True, auto_hex=True):
- data = part.get_content(name)
+ data = part.extractdata(name)
# check for zip content
if name.endswith(".gz") and auto_decompress:
io = StringIO(data)
@@ -550,24 +550,16 @@ class DebPackage(object):
def control_content(self, name):
""" return the content of a specific control.tar.gz file """
try:
- from debian.debfile import DebFile
- except:
- raise Exception(_("Python-debian module not available"))
- control = DebFile(self.filename).control
- if name in control:
- return self._get_content(control, name)
- return ""
+ return self._get_content(self._debfile.control, name)
+ except LookupError:
+ return ""
def data_content(self, name):
""" return the content of a specific control.tar.gz file """
try:
- from debian.debfile import DebFile
- except:
- raise Exception(_("Python-debian module not available"))
- data = DebFile(self.filename).data
- if name in data:
- return self._get_content(data, name)
- return ""
+ return self._get_content(self._debfile.data, name)
+ except LookupError:
+ return ""
def _dbg(self, level, msg):
"""Write debugging output to sys.stderr."""
--
Julian Andres Klode - Debian Developer, Ubuntu Member
See http://wiki.debian.org/JulianAndresKlode and http://jak-linux.org/.
Reply to: