From bb68ad4269cbb4900e9eca1f8a0fa582b895d5b2 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Sat, 10 Sep 2016 12:23:44 -0700 Subject: [PATCH] Annotate bots/summarize_stream.py. --- bots/summarize_stream.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bots/summarize_stream.py b/bots/summarize_stream.py index b27c68a..d48adfb 100644 --- a/bots/summarize_stream.py +++ b/bots/summarize_stream.py @@ -7,8 +7,9 @@ import zulip import re import collections -def get_recent_messages(client, narrow, count=100): - narrow = [word.split(':') for word in narrow.split()] +def get_recent_messages(client, narrow_str, count=100): + # type: (zulip.Client, str, int) -> List[Dict[str, Any]] + narrow = [word.split(':') for word in narrow_str.split()] req = { 'narrow': narrow, 'num_before': count, @@ -22,6 +23,7 @@ def get_recent_messages(client, narrow, count=100): return old_messages['messages'] def get_words(content): + # type: (str) -> List[str] regex = "[A-Z]{2,}(?![a-z])|[A-Z][a-z]+(?=[A-Z])|[\'\w\-]+" words = re.findall(regex, content, re.M) words = [w.lower() for w in words] @@ -29,6 +31,7 @@ def get_words(content): return words def analyze_messages(msgs, word_count, email_count): + # type: (List[Dict[str, Any]], Dict[str, int], Dict[str, int]) -> None for msg in msgs: if False: if ' ack' in msg['content']: @@ -47,6 +50,7 @@ def analyze_messages(msgs, word_count, email_count): print('%-20s: %s' % (k, v)) def generate_support_stats(): + # type: () -> None client = zulip.Client() narrow = 'stream:support' count = 2000