Package: python-apt Version: 0.8.9.1 Severity: wishlist Tags: patch A removed-but-not-purged package will have is_installed() evaluate to False. There seems to be no obvious way to test whether a package has just been removed, or also purged.
Here's one, because a removed-but-not-purged has at least one entry in the installed_files list: # python -c "import apt; c=apt.Cache(); c.update(); c.open(); p=c['ruby1.8']; print p, p.installed, p.installed_files" <Package: name:'ruby1.8' id:1425> None [u''] # dpkg --purge ruby1.8 (Reading database ... 27904 files and directories currently installed.) Removing ruby1.8 ... Purging configuration files for ruby1.8 ... # python -c "import apt; c=apt.Cache(); c.update(); c.open(); p=c['ruby1.8']; print p, p.installed, p.installed_files" <Package: name:'ruby1.8' id:1425> None [] I leave it up to you to decide if this is the right approach: --- /usr/lib/python2.7/dist-packages/apt/package.py 2013-06-06 18:32:36.000000000 +0200 +++ /tmp/package.py 2013-06-19 09:27:10.185973295 +0200 @@ -985,6 +985,11 @@ return (self._pkg.current_ver is not None) @property + def is_purged(self): + """Return ``True`` if the package is purged (not just removed).""" + return not (self.is_installed or len(self.installed_files) > 0) + + @property def is_upgradable(self): """Return ``True`` if the package is upgradable.""" return (self.is_installed and -- System Information: Debian Release: jessie/sid APT prefers unstable APT policy: (500, 'unstable'), (1, 'experimental') Architecture: amd64 (x86_64) Fle: LANG=en_NZ, LC_CTYPE=en_NZ.UTF-8 (charmap=UTF-8ign Architectures: i386 Kernel: Linux 3.10-rc4-amd64 (SMP w/4 CP L Shell: /bin/sh linked to /bin/dash Versions of packages python-apt depends on: ii libapt-inst1.5 0.9.8.2 ii libapt-pkg4.12 0.9. ii libc6 2.17-5 ii libgcc1 1:4.8.1-3 ii libstdc++6 4.8.1-3 ii python 2.7.5-2 ii python-apt-common 0.8.9.1 Versions of packages python-apt recommends: ii iso-cndes 3.43-1 ii lsb-release 4.1+Debian12 ii xz-utils 5.1.1alpha+20120614-2 Versions of packages python-apt suggests: pn python-apt-dbg <none> pn python-apt-doc <none> ii python-gtk2 2.24.0-3+b1 ii python-vte 1:0.28.2-5 -- no debconf information -- .''`. martin f. krafft <madduck@d.o> Related projects: : :' : proud Debian developer http://debiansystem.info `. `'` http://people.debian.org/~madduck http://vcs-pkg.org `- Debian - when you have better things to do than fixing systems
digital_signature_gpg.asc
Description: Digital signature (see http://martin-krafft.net/gpg/sig-policy/999bbcc4/current)