diff options
author | Ben Finney <ben+python@benfinney.id.au> | 2018-04-23 16:16:27 +1000 |
---|---|---|
committer | Ben Finney <ben@benfinney.id.au> | 2018-04-23 19:23:21 +1000 |
commit | 6f36401bcaecc6583514e5530138a54f46f036c6 (patch) | |
tree | 72eaf543a82968d107c34bb838c949cb11a2f6d7 /alot/db/manager.py | |
parent | 2404bc62530c9c2715fb3b9d33a60f27b5a790ae (diff) |
Extract a level of nested conditionals for tag command.
Diffstat (limited to 'alot/db/manager.py')
-rw-r--r-- | alot/db/manager.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/alot/db/manager.py b/alot/db/manager.py index cbde9c88..057c72d0 100644 --- a/alot/db/manager.py +++ b/alot/db/manager.py @@ -160,15 +160,14 @@ class DBManager(object): for msg in query.search_messages(): msg.freeze() if cmd == 'tag': - for tag in tags: - msg.add_tag(tag, sync_maildir_flags=sync) + strategy = msg.add_tag if cmd == 'set': msg.remove_all_tags() - for tag in tags: - msg.add_tag(tag, sync_maildir_flags=sync) + strategy = msg.add_tag elif cmd == 'untag': - for tag in tags: - msg.remove_tag(tag, sync_maildir_flags=sync) + strategy = msg.remove_tag + for tag in tags: + strategy(tag, sync_maildir_flags=sync) msg.thaw() logging.debug('ended atomic') |