From 81517ae18df0eb6917abc5a6574868d213c3168d Mon Sep 17 00:00:00 2001 From: Sanjay Bhangar Date: Sun, 2 Dec 2018 16:29:55 +0200 Subject: [PATCH] fixes for python3 --- utils.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/utils.py b/utils.py index b93f0fd..defe0f0 100644 --- a/utils.py +++ b/utils.py @@ -2,13 +2,13 @@ from settings import username, password, url import ox import json import codecs -import urllib2 +from urllib.request import urlopen api = ox.api.API(url) user = api.signin({'username': username, 'password': password}) -if user['data'].has_key("errors"): - print "Authentication Failed!" +if 'errors' in user['data']: + print("Authentication Failed!") def titleContains(string): return api.find({ @@ -117,7 +117,7 @@ def replacePlaceNames(old, new, operator="", start=0, end=100): if new_value == '': log = "EMPTY VALUE: %s" % m['id'] logFile.write(log) - print log + print(log) continue ret.append(api.editAnnotation({ 'id': m['id'], @@ -127,7 +127,7 @@ def replacePlaceNames(old, new, operator="", start=0, end=100): })) log = "%s| %s| %s" % (m['id'], value, new_value,) logFile.write(log + "\n") - print log + print(log) logFile.close() return ret @@ -219,10 +219,10 @@ def getTranscriptsForList(listId='sanj:spaces of theatre'): items = [{'id': item['id'], 'title': item['title']} for item in result['data']['items']] outfolder = "out" for i in items: - print i['title'] + print(i['title']) savePath = "%s/%s_%s.txt" % (outfolder, i['id'], i['title']) transcript_url = 'http://pad.ma/%s/transcripts.srt' % i['id'] - txt = urllib2.urlopen(transcript_url).read() + txt = urlopen(transcript_url).read() outfile = open(savePath, "w") outfile.write(txt) outfile.close()