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>
objects.TaggableObject.ValidateTag(tag)
del_tags = frozenset(self.op.tags)
cur_tags = self.target.GetTags()
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" %
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.
def Exec(self, feedback_fn):
"""Remove the tag from the object.