1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264
|
From d475569265574be6e49ebf9a363c7e0325542be2 Mon Sep 17 00:00:00 2001
From: Julian Andres Klode <jak@debian.org>
Date: Sat, 27 Feb 2010 22:19:33 +0100
Subject: [PATCH] Update to new python-apt API.
---
debian/control | 2 +-
src/changes.py | 13 +++----
src/commands.py | 92 +++++++++++++++++++++++++++---------------------------
3 files changed, 53 insertions(+), 54 deletions(-)
diff --git a/debian/control b/debian/control
index 050e85c..1afc24a 100644
--- a/debian/control
+++ b/debian/control
@@ -11,7 +11,7 @@ Build-Depends: debhelper (>= 5.0.38)
Package: wajig
Architecture: all
XB-Python-Version: all
-Depends: ${python:Depends}, apt, python-apt, dselect
+Depends: ${python:Depends}, apt, python-apt (>= 0.7.93.2~), dselect
Suggests: wget, fping, debconf, reportbug, apt-move, dpkg-repack, alien, fakeroot, gkdebconf, lynx, python-gtk2, python-glade2, python-gnome2, gnome-terminal, locales, gnome-tasksel, deborphan, vrms, sudo, apt-show-versions, apt-listbugs
Description: simplified Debian package management front end
Wajig is a single commandline wrapper around apt, apt-cache, dpkg,
diff --git a/src/changes.py b/src/changes.py
index faf272e..1965c8d 100644
--- a/src/changes.py
+++ b/src/changes.py
@@ -382,11 +382,11 @@ def get_new_upgrades():
list Newly upgraded packages"""
load_dictionaries()
upgraded_list = []
- apt_pkg.InitSystem(); # Not sure why!
+ apt_pkg.init_system(); # Not sure why!
for pkg in installed_list.keys():
if available_list.has_key(pkg) \
and previous_list.has_key(pkg) \
- and apt_pkg.VersionCompare(available_list[pkg],
+ and apt_pkg.version_compare(available_list[pkg],
previous_list[pkg]) > 0:
upgraded_list.append(pkg)
return upgraded_list
@@ -401,19 +401,18 @@ def get_to_upgrade():
load_dictionaries()
upgraded_list = []
- apt_pkg.InitSystem(); # Not sure why!
+ apt_pkg.init_system(); # Not sure why!
for pkg in installed_list.keys():
if available_list.has_key(pkg) \
- and apt_pkg.VersionCompare(available_list[pkg],
+ and apt_pkg.version_compare(available_list[pkg],
installed_list[pkg]) > 0:
upgraded_list.append(pkg)
return upgraded_list
def get_status(pkg):
p = perform.execute("dpkg --status " + pkg, pipe=True)
- pkginfo = apt_pkg.ParseTagFile(p)
- pkginfo.Step()
- return pkginfo.Section.get("Status")
+ pkginfo = apt_pkg.TagFile(p)
+ return pkginfo.next().get("Status")
def get_dependees(pkg):
"""Return a list of other installed pkgs that depend on PKG."""
diff --git a/src/commands.py b/src/commands.py
index de8c62f..06a2fe7 100644
--- a/src/commands.py
+++ b/src/commands.py
@@ -94,12 +94,12 @@ def get_available(command="dumpavail"):
"Return an apt_pkg object that represents the parsed list of packages."
# This originally ran the apt-cache command as a pipe to
- # ParseTagFile as in:
+ # TagFile as in:
# command = "apt-cache dumpavail"
# packages_pipe = perform.execute(command, noquiet=True, pipe=True)
- # avail = apt_pkg.ParseTagFile(packages_pipe)
+ # avail = apt_pkg.TagFile(packages_pipe)
#
- # But as in Bug#366678 ParseTagFile no longer works in a pipe
+ # But as in Bug#366678 TagFile no longer works in a pipe
# because of changes to apt_pkg by Michael Vogt. He supplied
# suggested fixes, but they were not tested and I've not had
# a chance to understand the new APT package for Python. So put
@@ -117,7 +117,7 @@ def get_available(command="dumpavail"):
command = "cat /var/lib/dpkg/status >> " + tmpcache
perform.execute(command)
# 090501 End
- avail = apt_pkg.ParseTagFile(file(tmpcache))
+ avail = apt_pkg.TagFile(file(tmpcache))
if os.path.exists(tmpcache): os.remove(tmpcache)
return(avail)
@@ -134,14 +134,14 @@ def do_dependents(package):
#
# Check for information in the Available list
#
- while avail.Step():
- nam = avail.Section.get("Package")
+ for section in avail:
+ nam = section.get("Package")
if (nam in pkgs):
- dep = avail.Section.get("Depends")
- sug = avail.Section.get("Suggests")
- rec = avail.Section.get("Recommends")
- con = avail.Section.get("Conflicts")
- rep = avail.Section.get("Replaces")
+ dep = section.get("Depends")
+ sug = section.get("Suggests")
+ rec = section.get("Recommends")
+ con = section.get("Conflicts")
+ rep = section.get("Replaces")
if not dep: dep = ""
if not sug: sug = ""
if not rec: rec = ""
@@ -209,9 +209,9 @@ def do_describe(packages):
# apt-cache dumpavail > /tmp/avail
# dpkg --update-avail /tmp/avail
#
- # avail = apt_pkg.ParseTagFile(open("/var/cache/apt/available","r"));
- # avail = apt_pkg.ParseTagFile(open("/var/cache/apt/pkgcache.bin","r"));
- # avail = apt_pkg.ParseTagFile(open("/var/lib/dpkg/available","r"))
+ # avail = apt_pkg.TagFile(open("/var/cache/apt/available","r"));
+ # avail = apt_pkg.TagFile(open("/var/cache/apt/pkgcache.bin","r"));
+ # avail = apt_pkg.TagFile(open("/var/lib/dpkg/available","r"))
#
# Simplest solution seems to be to pipe details of all packages
# from apt-cache (which needs sudo). 23 Aug 2003.
@@ -260,10 +260,10 @@ def do_describe(packages):
#
# Check for information in the Available list
#
- while avail.Step():
- if (avail.Section.get("Package") in packages):
- package_name = avail.Section.get("Package")
- package_description = avail.Section.get("Description")
+ for section in avail:
+ if (section.get("Package") in packages):
+ package_name = section.get("Package")
+ package_description = section.get("Description")
if not describe_list.has_key(package_name):
describe_list[package_name] = package_description
# Bug fix for Bug#366678 Part 2 - not working yet???
@@ -600,10 +600,10 @@ def do_install_suggest(packages, type, noauth=""):
#
# Check for information in the Available list
#
- while avail.Step():
- if (avail.Section.get("Package") in packages):
- sug = avail.Section.get("Suggests")
- rec = avail.Section.get("Recommends")
+ for section in avail:
+ if (section.get("Package") in packages):
+ sug = section.get("Suggests")
+ rec = section.get("Recommends")
if type == "Suggests" or type == "Both":
if sug: suggest_list = suggest_list+" "+sug
if type == "Recommends" or type == "Both":
@@ -652,17 +652,17 @@ def do_install_suggest(packages, type, noauth=""):
def do_listsections():
avail = get_available()
sections = []
- while avail.Step():
- s = avail.Section.get("Section")
+ for section in avail:
+ s = section.get("Section")
if s not in sections:
sections.append(s)
print "\n".join(sections)
def do_listsection(pattern):
avail = get_available()
- while avail.Step():
- if (pattern == avail.Section.get("Section")):
- print avail.Section.get("Package")
+ for section in avail:
+ if (pattern == section.get("Section")):
+ print section.get("Package")
#------------------------------------------------------------------------
#
@@ -757,18 +757,18 @@ def map_sources(packages):
Note that the source could include a version number.
Only replace with source if package exists (Bug#295455).
"""
- Parse = apt_pkg.ParseTagFile(open("/var/lib/dpkg/available","r"))
+ tagfile = apt_pkg.TagFile(open("/var/lib/dpkg/available","r"))
sources = []
- while Parse.Step():
+ for section in tagfile:
# May want to look to terminate as soon as all packages
# have been found - to be more efficient
- if Parse.Section.get("Package") in packages:
- if Parse.Section.get("Source"):
- #pkgname = Parse.Section.get("Source").split()[0]
- pkgname = Parse.Section.get("Source")
- sources += [[pkgname, Parse.Section.get("Package")]]
+ if section.get("Package") in packages:
+ if section.get("Source"):
+ #pkgname = section.get("Source").split()[0]
+ pkgname = section.get("Source")
+ sources += [[pkgname, section.get("Package")]]
else:
- sources += [[Parse.Section.get("Package"), Parse.Section.get("Package")]]
+ sources += [[section.get("Package"), section.get("Package")]]
return sources
def do_news(packages):
@@ -835,7 +835,7 @@ def do_news(packages):
# #
# command = "apt-cache show " + package
# packages_pipe = perform.execute(command, noquiet=True, pipe=True)
-# Parse = apt_pkg.ParseTagFile(packages_pipe)
+# Parse = apt_pkg.TagFile(packages_pipe)
# version = '0'
# filename = ''
# while Parse.Step():
@@ -1002,7 +1002,7 @@ def do_size(packages, size):
# Work with the list of installed packages
# (I think status has more than installed?)
#
- status = apt_pkg.ParseTagFile(open("/var/lib/dpkg/status","r"));
+ status = apt_pkg.TagFile(open("/var/lib/dpkg/status","r"));
#
# Initialise the sizes dictionary.
#
@@ -1011,11 +1011,11 @@ def do_size(packages, size):
#
# Check for information in the Status list
#
- while status.Step():
- if not packages or status.Section.get("Package") in packages:
- package_name = status.Section.get("Package")
- package_size = status.Section.get("Installed-Size")
- package_status = re.split(" ", status.Section.get("Status"))[2]
+ for section in status:
+ if not packages or section.get("Package") in packages:
+ package_name = section.get("Package")
+ package_size = section.get("Installed-Size")
+ package_status = re.split(" ", section.get("Status"))[2]
if package_size and int(package_size) > size:
if not size_list.has_key(package_name):
size_list[package_name] = package_size
@@ -1489,11 +1489,11 @@ def do_recdownload(packages):
Author: Juanjo Alvarez <juanjux@yahoo.es>"""
def get_deps(package):
- Parse = apt_pkg.ParseTagFile(open("/var/lib/dpkg/available","r"))
+ tagfile = apt_pkg.TagFile(open("/var/lib/dpkg/available","r"))
deplist = []
- while Parse.Step():
- if Parse.Section.get("Package")==package:
- deplist = apt_pkg.ParseDepends(Parse.Section.get("Depends",""))
+ for section in tagfile:
+ if section.get("Package")==package:
+ deplist = apt_pkg.parse_depends(section.get("Depends",""))
break
realdeplist = []
if deplist != []:
--
1.7.0
|