installdb,cli/listinstalled: Thinko fix

The build host should be an empty string for old packages.
"pisi li -b ''" now returns old packages, too.
This commit is contained in:
Fatih Aşıcı
2010-10-06 20:53:09 +00:00
parent b2514b62cc
commit 4a7d58c51e
2 changed files with 12 additions and 6 deletions
+2 -2
View File
@@ -41,7 +41,7 @@ Usage: list-installed
group.add_option("-b", "--with-build-host",
action="store",
default="localhost",
default=None,
help=_("Only list the installed packages built "
"by the given host"))
group.add_option("-l", "--long", action="store_true",
@@ -57,7 +57,7 @@ Usage: list-installed
self.init(database = True, write = False)
build_host = ctx.get_option("with_build_host")
if not build_host:
if build_host is None:
installed = self.installdb.list_installed()
else:
installed = self.installdb.list_installed_with_build_host(build_host)
+10 -4
View File
@@ -118,13 +118,19 @@ class InstallDB(lazydb.LazyDB):
return self.installed_db.has_key(package)
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)
build_host_re = re.compile("<BuildHost>(.*?)</BuildHost>")
found = []
for name in self.list_installed():
xml = open(os.path.join(self.package_path(name), ctx.const.metadata_xml)).read()
if build_host_re.search(xml):
found.append(name)
matched = build_host_re.search(xml)
if matched:
if build_host != matched.groups()[0]:
continue
elif build_host:
continue
found.append(name)
return found
def __get_version(self, meta_doc):