Run transbot through 2to3

This commit is contained in:
Klaus-Uwe Mitterer 2017-02-28 11:02:43 +01:00
parent 101b8071b9
commit ffef5cc47d

View file

@ -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))