On 2012-10-25 23:24, James Antill wrote: > Yeh, if we can only have one I guess nvra is better ... for those few > times we want/need to specify a version, but it feels like the common > case would get less nice.
Attached is another stab at this; this time outputting nvra only for installonlypkgs, and na for others. I think this would be a good improvement and not make the the general cases uglier. The installonly filtering logic is basically copy/pasted from TransactionData._allowedMultipleInstalls(); I suppose that's not available in a form that could be reused here ATM.
>From 5dbad0176c3e3fe36c6a7c8b20cb3ee81afd5ce4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= <[email protected]> Date: Thu, 25 Oct 2012 00:06:05 +0300 Subject: [PATCH] bash completion: offer nvra instead of na strings for installonly packages. Helps dealing with packages with multiple versions installed/available etc. --- completion-helper.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/completion-helper.py b/completion-helper.py index 05801d1..03ce3c7 100755 --- a/completion-helper.py +++ b/completion-helper.py @@ -41,14 +41,21 @@ class GroupsCompletionCommand(yumcommands.GroupsCommand): class ListCompletionCommand(yumcommands.ListCommand): def doCommand(self, base, basecmd, extcmds): + def printPkgs(pkgs): + for pkg in pkgs: + if pkg.name in base.conf.installonlypkgs or \ + filter(lambda prov: prov in base.conf.installonlypkgs, + pkg.provides_names): + print pkg.nvra + else: + print pkg.na + ypl = base.doPackageLists(pkgnarrow=extcmds[0], patterns=[get_pattern(extcmds)]) if extcmds[0] in ("installed", "all"): - for pkg in ypl.installed: - print pkg.na + printPkgs(ypl.installed) if extcmds[0] in ("available", "all"): - for pkg in ypl.available: - print pkg.na + printPkgs(ypl.available) class RepoListCompletionCommand(yumcommands.RepoListCommand): def doCommand(self, base, basecmd, extcmds): -- 1.7.11.7
_______________________________________________ Yum-devel mailing list [email protected] http://lists.baseurl.org/mailman/listinfo/yum-devel
