On Wed, Jun 19, 2013 at 09:27:42AM +0200, martin f krafft wrote: > 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. [...] > 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 This tells you whether a package is not purged (that is, in config file status): self. _pkg.current_state == apt_pkg.CURSTATE_CONFIG_FILES The name 'is_purged' might be a bit confusing for never-installed packages, and maybe it's better to use a negated property like 'is_not_purged'. -- Julian Andres Klode - Debian Developer, Ubuntu Member See http://wiki.debian.org/JulianAndresKlode and http://jak-linux.org/.
Attachment:
pgpJ5QIL_oXWl.pgp
Description: PGP signature