From 0cacd2d0c740ca9553f177c2332a613c7485856b Mon Sep 17 00:00:00 2001 From: Klaus-Uwe Mitterer Date: Sat, 25 Apr 2015 01:25:33 +0200 Subject: [PATCH] Add -w switch to getmentions allowing to get stats for all words (whitespace-delimited strings) ever tweeted --- getmentions.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/getmentions.py b/getmentions.py index b68d765..cc7391c 100755 --- a/getmentions.py +++ b/getmentions.py @@ -13,8 +13,11 @@ def getTweets(mode = "@", path = tools.config.dbpath): for tweet in tweets: for word in tweet[0].split(): - if word[0] == mode: - handle = mode + re.split('[\\W]',word[1:])[0].lower() + if word[0] == mode or mode == "": + if mode == "": + handle = word + else: + handle = mode + re.split('[\\W]',word[1:])[0].lower() if handle != mode: try: handles[handle] += 1 @@ -34,6 +37,8 @@ if __name__ == "__main__": for arg in sys.argv[1:]: if arg == "-h": mode = "#" + if arg == "-w": + mode = "" else: path = arg