diff options
author | Patrick Totzke <patricktotzke@gmail.com> | 2012-01-07 17:16:41 +0000 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2012-01-07 17:16:41 +0000 |
commit | dbf341defed3d1158778611f157945b0ce554381 (patch) | |
tree | 02b5d6f69958cc6f62963d3b9de4081dcb2e8d04 /alot | |
parent | ca6dc2aa632307e9f33dedd402443c6cac87501d (diff) |
intersection arg for Thread.get_tags()
return tags present in all contained messages
instead of in at least one (union)
Diffstat (limited to 'alot')
-rw-r--r-- | alot/db.py | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -362,15 +362,20 @@ class Thread(object): """returns id of this thread""" return self._id - def get_tags(self): + def get_tags(self, intersection=False): """ returns tagsstrings attached to this thread - :rtype: list of str + :param intersection: return tags present in all contained messages + instead of in at least one (union) + :type intersection: bool + :rtype: set of str """ - l = list(self._tags) - l.sort() - return l + tags = set(list(self._tags)) + if intersection: + for m in self.get_messages().keys(): + tags = tags.intersection(set(m.get_tags())) + return tags def add_tags(self, tags): """ |