slack: Lookup dir_name key in dict instead of in dict_keys.

No reason to do the lookup in O(n) when we can do
it in average O(1) time complexity.
This commit is contained in:
Vishnu KS 2019-08-12 16:28:54 +05:30 committed by Tim Abbott
parent 1e5c49ad82
commit 3650f19692
1 changed files with 3 additions and 3 deletions

View File

@ -636,11 +636,11 @@ def get_messages_iterator(slack_data_dir: str, added_channels: Dict[str, Any],
dir_name = os.path.basename(dir_path) dir_name = os.path.basename(dir_path)
for message in messages: for message in messages:
# To give every message the channel information # To give every message the channel information
if dir_name in added_channels.keys(): if dir_name in added_channels:
message['channel_name'] = dir_name message['channel_name'] = dir_name
elif dir_name in added_mpims.keys(): elif dir_name in added_mpims:
message['mpim_name'] = dir_name message['mpim_name'] = dir_name
elif dir_name in dm_members.keys(): elif dir_name in dm_members:
message['pm_name'] = dir_name message['pm_name'] = dir_name
messages_for_one_day += messages messages_for_one_day += messages