From de312e4138229857498c220baed4c8e38016d061 Mon Sep 17 00:00:00 2001 From: "Adam D. Barratt" Date: Sun, 6 Mar 2011 20:52:05 +0000 Subject: [PATCH] Add support for the python-apt 0.8 API. Starting with version 0.7.100, python-apt introduced a new API which replaced several functions which created objects with real classes and updated a number of method names to be PEP8 compliant. --- britney.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/britney.py b/britney.py index 9d01abf..3d1aa97 100755 --- a/britney.py +++ b/britney.py @@ -409,9 +409,15 @@ class Britney: package = None filename = os.path.join(basedir, "Sources") self.__log("Loading source packages from %s" % filename) - Packages = apt_pkg.ParseTagFile(open(filename)) - get_field = Packages.Section.get - while Packages.Step(): + try: + Packages = apt_pkg.TagFile(open(filename)) + get_field = Packages.section.get + step = Packages.step + except AttributeError, e: + Packages = apt_pkg.ParseTagFile(open(filename)) + get_field = Packages.Section.get + step = Packages.Step + while step(): pkg = get_field('Package') ver = get_field('Version') # There may be multiple versions of the source package @@ -459,9 +465,15 @@ class Britney: filename = os.path.join(basedir, "Packages_%s" % arch) self.__log("Loading binary packages from %s" % filename) - Packages = apt_pkg.ParseTagFile(open(filename)) - get_field = Packages.Section.get - while Packages.Step(): + try: + Packages = apt_pkg.TagFile(open(filename)) + get_field = Packages.section.get + step = Packages.step + except AttributeError, e: + Packages = apt_pkg.ParseTagFile(open(filename)) + get_field = Packages.Section.get + step = Packages.Step + while step(): pkg = get_field('Package') version = get_field('Version')