diff options
author | Anton Khirnov <anton@khirnov.net> | 2020-05-24 13:14:33 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2020-05-24 14:01:09 +0200 |
commit | c8f3d99eab089d337e5fdcb8ff39efd6ab1aa5e9 (patch) | |
tree | f5e269b6d85d078e0ad43cfde1c36a56ecca0b0e /alot/commands | |
parent | b1f6be9d1808406c94c5c033b50abb5f7517e82b (diff) |
Consistently use set/frozenset for tags.
Diffstat (limited to 'alot/commands')
-rw-r--r-- | alot/commands/globals.py | 4 | ||||
-rw-r--r-- | alot/commands/search.py | 10 | ||||
-rw-r--r-- | alot/commands/thread.py | 11 |
3 files changed, 12 insertions, 13 deletions
diff --git a/alot/commands/globals.py b/alot/commands/globals.py index b803b9fd..c2128135 100644 --- a/alot/commands/globals.py +++ b/alot/commands/globals.py @@ -563,7 +563,7 @@ class TagListCommand(Command): Command.__init__(self, **kwargs) def apply(self, ui): - tags = self.tags or ui.dbman.get_all_tags() + tags = frozenset(self.tags) if self.tags else ui.dbman.get_all_tags() blists = ui.get_buffers_of_type(buffers.TagListBuffer) if blists: buf = blists[0] @@ -977,7 +977,7 @@ class ComposeCommand(Command): if self.bcc: self.envelope.add('Bcc', ','.join(self.bcc)) if self.tags: - self.envelope.tags = [t for t in self.tags.split(',') if t] + self.envelope.tags = frozenset(filter(None, self.tags.split(','))) async def _set_subject(self, ui): if settings.get('ask_subject') and \ diff --git a/alot/commands/search.py b/alot/commands/search.py index 5d7a7cbd..8e959e65 100644 --- a/alot/commands/search.py +++ b/alot/commands/search.py @@ -196,7 +196,7 @@ class TagCommand(Command): ui.update() - tags = [x for x in self.tagsstring.split(',') if x] + tags = frozenset(filter(None, self.tagsstring.split(','))) try: if self.action == 'add': @@ -207,13 +207,13 @@ class TagCommand(Command): ui.dbman.untag(testquery, tags) elif self.action == 'toggle': if not self.allm: - to_remove = [] - to_add = [] + to_remove = set() + to_add = () for t in tags: if t in thread.get_tags(): - to_remove.append(t) + to_remove.add(t) else: - to_add.append(t) + to_add.add(t) thread.remove_tags(to_remove) thread.add_tags(to_add, afterwards=refresh) except DatabaseROError: diff --git a/alot/commands/thread.py b/alot/commands/thread.py index de948747..1da58560 100644 --- a/alot/commands/thread.py +++ b/alot/commands/thread.py @@ -483,7 +483,6 @@ class EditNewCommand(Command): tags = set(self.message.get_tags()) tags.difference_update({'inbox', 'sent', 'draft', 'killed', 'replied', 'signed', 'encrypted', 'unread', 'attachment'}) - tags = list(tags) # set body text mailcontent = self.message.get_body_text() envelope = Envelope(bodytext=mailcontent, tags=tags) @@ -1078,7 +1077,7 @@ class TagCommand(Command): else: messages = [ui.current_buffer.get_selected_message()] - tags = [t for t in self.tagsstring.split(',') if t] + tags = frozenset(filter(None, self.tagsstring.split(','))) try: for m in messages: if self.action == 'add': @@ -1088,13 +1087,13 @@ class TagCommand(Command): elif self.action == 'remove': m.remove_tags(tags) elif self.action == 'toggle': - to_remove = [] - to_add = [] + to_remove = set() + to_add = () for t in tags: if t in m.get_tags(): - to_remove.append(t) + to_remove.add(t) else: - to_add.append(t) + to_add.add(t) m.remove_tags(to_remove) m.add_tags(to_add) |