From 91c69b44249f38761daede714b2af2ae3b11c321 Mon Sep 17 00:00:00 2001 From: Michael Hanselmann <hansmi@google.com> Date: Fri, 1 Oct 2010 16:59:59 +0200 Subject: [PATCH] LUDelTags: Improve formatting of error message Use utils.CommaJoin to add spaces after comma, clean up code a bit. Before: Tag(s) 'bar','baz','foo','moo' not found After: Tag(s) 'bar', 'baz', 'foo', 'moo' not found Signed-off-by: Michael Hanselmann <hansmi@google.com> Reviewed-by: Iustin Pop <iustin@google.com> --- lib/cmdlib.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 8d0b9baf3..daaee2264 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -9927,12 +9927,13 @@ class LUDelTags(TagsLU): objects.TaggableObject.ValidateTag(tag) del_tags = frozenset(self.op.tags) cur_tags = self.target.GetTags() - if not del_tags <= cur_tags: - diff_tags = del_tags - cur_tags - diff_names = ["'%s'" % tag for tag in diff_tags] - diff_names.sort() + + diff_tags = del_tags - cur_tags + if diff_tags: + diff_names = ("'%s'" % i for i in sorted(diff_tags)) raise errors.OpPrereqError("Tag(s) %s not found" % - (",".join(diff_names)), errors.ECODE_NOENT) + (utils.CommaJoin(diff_names), ), + errors.ECODE_NOENT) def Exec(self, feedback_fn): """Remove the tag from the object. -- GitLab