This commit is contained in:
Faik Uygur
2005-11-08 23:14:03 +00:00
parent 78f154a6b4
commit b38df341eb
2 changed files with 21 additions and 6 deletions
+11 -6
View File
@@ -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)
+10
View File
@@ -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