Cleanups:

* Don't reference __class__ when we can use the instance itself
* use isdisjoint() as it can stop once a match is found
* Remove a condtional that was taken care of in the conditonal just above
This commit is contained in:
Toshio Kuratomi 2015-07-23 12:11:10 -07:00
commit f8e4aff4c1
3 changed files with 10 additions and 13 deletions

View file

@ -28,7 +28,7 @@ from ansible.template import Templar
class Taggable:
untagged = set(['untagged'])
untagged = frozenset(['untagged'])
_tags = FieldAttribute(isa='list', default=[], listof=(string_types,int))
def __init__(self):
@ -70,8 +70,8 @@ class Taggable:
else:
tags = set([i for i,_ in itertools.groupby(tags)])
else:
# this makes intersection work for untagged
tags = self.__class__.untagged
# this makes isdisjoint work for untagged
tags = self.untagged
if only_tags:
@ -79,9 +79,9 @@ class Taggable:
if 'always' in tags or 'all' in only_tags:
should_run = True
elif tags.intersection(only_tags):
elif not tags.isdisjoint(only_tags):
should_run = True
elif 'tagged' in only_tags and tags != self.__class__.untagged:
elif 'tagged' in only_tags and tags != self.untagged:
should_run = True
if should_run and skip_tags:
@ -90,9 +90,9 @@ class Taggable:
if 'all' in skip_tags:
if 'always' not in tags or 'always' in skip_tags:
should_run = False
elif tags.intersection(skip_tags):
elif not tags.isdisjoint(skip_tags):
should_run = False
elif 'tagged' in skip_tags and tags != self.__class__.untagged:
elif 'tagged' in skip_tags and tags != self.untagged:
should_run = False
return should_run