From b38df341ebd43894ad1be57733d60e76081980fe Mon Sep 17 00:00:00 2001 From: Faik Uygur Date: Tue, 8 Nov 2005 23:14:03 +0000 Subject: [PATCH] fixes #681 --- pisi/cli/commands.py | 17 +++++++++++------ pisi/files.py | 10 ++++++++++ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/pisi/cli/commands.py b/pisi/cli/commands.py index 4e67133c..934bcdba 100644 --- a/pisi/cli/commands.py +++ b/pisi/cli/commands.py @@ -905,13 +905,18 @@ Finds the installed package which contains the specified file. default=False, help="show in long format") def search_exact(path): + import os.path + path = path.lstrip('/') #FIXME: this shouldn't be necessary :/ - if ctx.filesdb.has_file(path): - (pkg_name, file_info) = ctx.filesdb.get_file(path) - ctx.ui.info(_('Package: %s') % pkg_name) - if ctx.config.options.long: - ctx.ui.info(_('Type: %s, Hash: %s') % (file_info.type, - file_info.hash) ) + files = ctx.filesdb.get_files(path) + + if files: + for (pkg_name, file_info) in files: + #FIXME: there can be a prettier info line + ctx.ui.info(_('Package: %s has File: %s') % (pkg_name, file_info.path)) + if ctx.config.options.long: + ctx.ui.info(_('Type: %s, Hash: %s') % (file_info.type, + file_info.hash) ) else: ctx.ui.error(_('Path %s does not belong to an installed package') % path) search_exact=staticmethod(search_exact) diff --git a/pisi/files.py b/pisi/files.py index 98ab6cb2..2db0bb75 100644 --- a/pisi/files.py +++ b/pisi/files.py @@ -67,3 +67,13 @@ class FilesDB(shelve.LockedDBShelf): return None else: return self[path] + + def get_files(self, file): + infos = [] + file = str(file) + + for key in self.keys(): + if key.find(file) >= 0: + infos.append(self[key]) + + return infos