summaryrefslogtreecommitdiff
path: root/alot
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2012-01-07 17:16:41 +0000
committerPatrick Totzke <patricktotzke@gmail.com>2012-01-07 17:16:41 +0000
commitdbf341defed3d1158778611f157945b0ce554381 (patch)
tree02b5d6f69958cc6f62963d3b9de4081dcb2e8d04 /alot
parentca6dc2aa632307e9f33dedd402443c6cac87501d (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.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/alot/db.py b/alot/db.py
index 4a663ee3..06c8c1e5 100644
--- a/alot/db.py
+++ b/alot/db.py
@@ -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):
"""