From ffef5cc47dd2b4bfdca2d7da88dfd74362e99d59 Mon Sep 17 00:00:00 2001 From: Klaus-Uwe Mitterer Date: Tue, 28 Feb 2017 11:02:43 +0100 Subject: [PATCH] Run transbot through 2to3 --- transbot.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/transbot.py b/transbot.py index bc06f1d..28a22dd 100644 --- a/transbot.py +++ b/transbot.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -import HTMLParser, tweepy, os, translate +import html.parser, tweepy, os, translate # [target_language,cons_key,cons_secret,access_token,access_secret] @@ -25,9 +25,9 @@ try: savepoint = file.read() except IOError: savepoint = "" - print "No savepoint found. Trying to get as many results as possible." + print("No savepoint found. Trying to get as many results as possible.") -timelineIterator = tweepy.Cursor(api.search, q=search, since_id=savepoint).items() +timelineIterator = list(tweepy.Cursor(api.search, q=search, since_id=savepoint).items()) timeline = [] @@ -40,12 +40,12 @@ tw_counter = 0 er_counter = 0 for status in timeline: - print "(%(date)s) %(name)s: %(message)s\n" % \ + print("(%(date)s) %(name)s: %(message)s\n" % \ { "date" : status.created_at, "name" : status.author.screen_name.encode('utf-8'), - "message" : status.text.encode('utf-8') } + "message" : status.text.encode('utf-8') }) - text = HTMLParser.HTMLParser().unescape(status.text).encode('utf-8') + text = html.parser.HTMLParser().unescape(status.text).encode('utf-8') if text[0] == "@": continue @@ -70,12 +70,12 @@ for status in timeline: try: api.update_status(tstring.encode('utf-8')[:140]) tw_counter += 1 - except tweepy.error.TweepError, e: - print e + except tweepy.error.TweepError as e: + print(e) er_counter += 1 continue with open(last_id_file, "w") as file: file.write(str(status.id)) -print "Finished. %d Tweets retweeted. %d errors occurred." % (tw_counter, er_counter) +print("Finished. %d Tweets retweeted. %d errors occurred." % (tw_counter, er_counter))