#!/usr/bin/env python3
import sys
import os
import analyzer
import helpers
from termcolor import colored
def main():
if len(sys.argv) != 2:
sys.exit("Usage ./tweets user")
positives = os.path.join(sys.path[0], "positive-words.txt")
negatives = os.path.join(sys.path[0], "negative-words.txt")
tweet_analyzer = analyzer.Analyzer(positives, negatives)
user = sys.argv[1].replace("@","")
Tweets = helpers.get_user_timeline(user)
score = 0
for Tweet in Tweets:
score = tweet_analyzer.analyze(Tweet)
if score > 0.0:
print(colored("{} {}",score, Tweet, "green"))
elif score < 0.0:
print(colored("{} {}",score, Tweet, "red"))
else:
print(colored("{} {}",score, Tweet, "yellow"))
score = 0
if __name__ == "main":
main()
My code doesn't print any output and I am not able to figure out why. Any help would be appreciated.
Tweets
containing anything? Ifget_user_timeline
fails, it probably returnsNone