Bug#150091: python-apt: please add a more comprehnsive usage example [included]
Package: python-apt
Version: 0.5.4.3
Severity: wishlist
Tags: patch
The following program checks the database and installed packages, and
spits out information about upgradable, uninstalled and updated packages.
diff -urN python-apt-0.5.4.3.before-changes/doc/examples/checkstate.py python-apt-0.5.4.3/doc/examples/checkstate.py
--- python-apt-0.5.4.3.before-changes/doc/examples/checkstate.py Thu Jan 1 02:00:00 1970
+++ python-apt-0.5.4.3/doc/examples/checkstate.py Sat Jun 15 21:02:31 2002
@@ -0,0 +1,31 @@
+#!/usr/bin/python2.1
+
+import apt_pkg
+apt_pkg.init()
+
+cache = apt_pkg.GetCache()
+packages = cache.Packages
+
+uninstalled, updated, upgradable = {}, {}, {}
+
+for package in packages:
+ versions = package.VersionList
+ if not versions:
+ continue
+ version = versions[0]
+ for other_version in versions:
+ if apt_pkg.VersionCompare(version.VerStr, other_version.VerStr)<0:
+ version = other_version
+ if package.CurrentVer:
+ current = package.CurrentVer
+ if apt_pkg.VersionCompare(current.VerStr, version.VerStr)<0:
+ upgradable[package.Name] = version
+ break
+ else:
+ updated[package.Name] = current
+ else:
+ uninstalled[package.Name] = version
+
+
+for l in (uninstalled, updated, upgradable):
+ print l.items()[0]
diff -urN python-apt-0.5.4.3.before-changes/doc/makefile python-apt-0.5.4.3/doc/makefile
--- python-apt-0.5.4.3.before-changes/doc/makefile Sat Jun 15 21:01:41 2002
+++ python-apt-0.5.4.3/doc/makefile Sat Jun 15 21:02:20 2002
@@ -7,6 +7,6 @@
# Examples
SOURCE = examples/config.py examples/configisc.py examples/tagfile.py \
- examples/versiontest.py
+ examples/versiontest.py examples/checkstate.py
TO = $(DOC)
include $(COPY_H)
--
To UNSUBSCRIBE, email to deity-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Reply to: