From 04d88e01e079388a17224286024d82e896ec1f5a Mon Sep 17 00:00:00 2001 From: Faik Uygur Date: Thu, 28 Feb 2008 08:25:50 +0000 Subject: [PATCH] pisi li -b lists installed packages without build nos. --- pisi/cli/listinstalled.py | 8 +++++++- pisi/db/installdb.py | 9 +++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/pisi/cli/listinstalled.py b/pisi/cli/listinstalled.py index c6971691..3426185b 100644 --- a/pisi/cli/listinstalled.py +++ b/pisi/cli/listinstalled.py @@ -40,6 +40,8 @@ Usage: list-installed group = optparse.OptionGroup(self.parser, _("list-installed options")) + group.add_option("-b", "--without-buildno", action="store_true", + default=False, help=_("Only list the installed packages without build nos")) group.add_option("-l", "--long", action="store_true", default=False, help=_("Show in long format")) group.add_option("-c", "--component", action="store", @@ -51,7 +53,11 @@ Usage: list-installed def run(self): self.init(database = True, write = False) - installed = self.installdb.list_installed() + + if not ctx.get_option('without_buildno'): + installed = self.installdb.list_installed() + else: + installed = self.installdb.list_installed_without_buildno() component = ctx.get_option('component') if component: diff --git a/pisi/db/installdb.py b/pisi/db/installdb.py index a4a1df64..5f399bfd 100644 --- a/pisi/db/installdb.py +++ b/pisi/db/installdb.py @@ -99,6 +99,15 @@ class InstallDB(lazydb.LazyDB): def has_package(self, package): return self.installed_db.has_key(package) + def list_installed_without_buildno(self): + rebuildno = '.*?' + found = [] + for name in self.list_installed(): + xml = open(os.path.join(self.package_path(name), ctx.const.metadata_xml)).read() + if not re.compile(rebuildno).search(xml): + found.append(name) + return found + def get_version(self, package): metadata_xml = os.path.join(self.package_path(package), ctx.const.metadata_xml)