Compare commits

..

2 Commits

2 changed files with 6 additions and 4 deletions

View File

@ -113,14 +113,16 @@ class TagLine(str):
Note that it's sufficient if the TagLine matches one of 'tags_or' or 'tags_and', Note that it's sufficient if the TagLine matches one of 'tags_or' or 'tags_and',
i. e. you can select a TagLine if it either contains one of the tags in 'tags_or' i. e. you can select a TagLine if it either contains one of the tags in 'tags_or'
or all of the tags in 'tags_and' but it must never contain any of the tags in or all of the tags in 'tags_and' but it must never contain any of the tags in
'tags_not'. 'tags_not'. If a given tag set is 'None', it matches all tags.
""" """
tag_set = self.tags() tag_set = self.tags()
required_tags_present = False required_tags_present = False
excluded_tags_missing = False excluded_tags_missing = False
if ((tags_or and any(tag in tag_set for tag in tags_or)) if ((tags_or is None and tags_and is None)
or (tags_or and any(tag in tag_set for tag in tags_or)) # noqa: W503
or (tags_and and all(tag in tag_set for tag in tags_and))): # noqa: W503 or (tags_and and all(tag in tag_set for tag in tags_and))): # noqa: W503
required_tags_present = True required_tags_present = True
if not any(tag in tag_set for tag in tags_not): if ((tags_not is None)
or (not any(tag in tag_set for tag in tags_not))): # noqa: W503
excluded_tags_missing = True excluded_tags_missing = True
return required_tags_present and excluded_tags_missing return required_tags_present and excluded_tags_missing

View File

@ -333,7 +333,7 @@ class TestTagLine(CmmTestCase):
self.assertFalse(tagline.match_tags(tags_or, tags_and, tags_not)) self.assertFalse(tagline.match_tags(tags_or, tags_and, tags_not))
# Test case 7: Some tags in 'tags_not' are present # Test case 7: Some tags in 'tags_not' are present
tags_or = set() tags_or = {Tag('tag1')}
tags_and = set() tags_and = set()
tags_not = {Tag('tag2')} tags_not = {Tag('tag2')}
self.assertFalse(tagline.match_tags(tags_or, tags_and, tags_not)) self.assertFalse(tagline.match_tags(tags_or, tags_and, tags_not))