trunk/pisi/pisi - cli/listinstalled: Replace --without-buildno with ...

Fatih Aşıcı uludag-commits at pardus.org.tr
6 Eki 2010 Çar 23:33:31 EEST


Author: fatih
Date: Wed Oct  6 23:33:31 2010
New Revision: 32236

Modified:
   trunk/pisi/pisi/cli/listinstalled.py
   trunk/pisi/pisi/db/installdb.py
Log:
cli/listinstalled: Replace --without-buildno with --with-build-host

This renamed parameter is used to filter packages by their build host.

  e.g. pisi li -b localhost

---
 cli/listinstalled.py |   14 +++++++++-----
 db/installdb.py      |    9 +++++----
 2 files changed, 14 insertions(+), 9 deletions(-)

Modified: trunk/pisi/pisi/cli/listinstalled.py
=================================================================
--- trunk/pisi/pisi/cli/listinstalled.py	(original)
+++ trunk/pisi/pisi/cli/listinstalled.py	Wed Oct  6 23:33:31 2010
@@ -1,6 +1,6 @@
 # -*- coding:utf-8 -*-
 #
-# Copyright (C) 2005 - 2007, TUBITAK/UEKAE
+# Copyright (C) 2005-2010, TUBITAK/UEKAE
 #
 # This program is free software; you can redistribute it and/or modify it under
 # the terms of the GNU General Public License as published by the Free
@@ -39,8 +39,11 @@
 
         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("-b", "--with-build-host",
+                         action="store",
+                         default="localhost",
+                         help=_("Only list the installed packages built "
+                                "by the given host"))
         group.add_option("-l", "--long", action="store_true",
                                default=False, help=_("Show in long format"))
         group.add_option("-c", "--component", action="store",
@@ -53,10 +56,11 @@
     def run(self):
         self.init(database = True, write = False)
 
-        if not ctx.get_option('without_buildno'):
+        build_host = ctx.get_option("with_build_host")
+        if not build_host:
             installed = self.installdb.list_installed()
         else:
-            installed = self.installdb.list_installed_without_buildno()
+            installed = self.installdb.list_installed_with_build_host(build_host)
 
         component = ctx.get_option('component')
         if component:

Modified: trunk/pisi/pisi/db/installdb.py
=================================================================
--- trunk/pisi/pisi/db/installdb.py	(original)
+++ trunk/pisi/pisi/db/installdb.py	Wed Oct  6 23:33:31 2010
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 #
-# Copyright (C) 2005 - 2010, TUBITAK/UEKAE
+# Copyright (C) 2005-2010, TUBITAK/UEKAE
 #
 # This program is free software; you can redistribute it and/or modify it under
 # the terms of the GNU General Public License as published by the Free
@@ -117,12 +117,13 @@
     def has_package(self, package):
         return self.installed_db.has_key(package)
 
-    def list_installed_without_buildno(self):
-        rebuildno = '<Build>.*?</Build>'
+    def list_installed_with_build_host(self, build_host):
+        xml_line = "<BuildHost>%s</BuildHost>" % re.escape(build_host)
+        build_host_re = re.compile(xml_line)
         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):
+            if build_host_re.search(xml):
                 found.append(name)
         return found
 


Uludag-commits mesaj listesiyle ilgili daha fazla bilgi