From 900386ad4615a3dbbc04501ef24c5a43385c6078 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Sat, 14 Jan 2023 16:34:44 +0900 Subject: Drop python2 support. Signed-off-by: Michele Calgaro --- knewsticker-scripts/fyensget.py | 18 +++++++++--------- knewsticker-scripts/sportscores.py | 34 +++++++++++++++++----------------- 2 files changed, 26 insertions(+), 26 deletions(-) (limited to 'knewsticker-scripts') diff --git a/knewsticker-scripts/fyensget.py b/knewsticker-scripts/fyensget.py index d93e13a..bfdae96 100755 --- a/knewsticker-scripts/fyensget.py +++ b/knewsticker-scripts/fyensget.py @@ -15,7 +15,7 @@ ### along with this program; if not, write to the Free Software ### Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -import urllib, re,string +import urllib.request, urllib.parse, urllib.error, re,string ################################################################################ # Groups of interest @@ -29,7 +29,7 @@ articleBase = "http://www.fyens.dk/" # Query the sections ################################################################################ def readSections(): - FILE=urllib.urlopen(base+"Menu.php") + FILE=urllib.request.urlopen(base+"Menu.php") REG=re.compile("(.*?)
") result=[] line=FILE.readline() @@ -46,20 +46,20 @@ def readSections(): # Fetch articles from a single section ################################################################################ def readSection( url, title ): - FILE=urllib.urlopen(base+url) + FILE=urllib.request.urlopen(base+url) REG=re.compile("(.*?)") line = FILE.readline() while line: match = REG.search(line) if match: - print "\n\t" + title + ": " +match.group(2) + "" - print "\t"+articleBase+match.group(1)+"\n" + print("\n\t" + title + ": " +match.group(2) + "") + print("\t"+articleBase+match.group(1)+"\n") line=FILE.readline() ################################################################################ # Print Header ################################################################################ -print """ +print(""" @@ -68,7 +68,7 @@ print """ dk http://www.fyens.dk/ Fyens Stiftstidende -""" +""") ################################################################################ # Main @@ -81,8 +81,8 @@ for (url, title) in l: ################################################################################ # Print footer. ################################################################################ -print """ +print(""" -""" +""") diff --git a/knewsticker-scripts/sportscores.py b/knewsticker-scripts/sportscores.py index ce9d04d..e9a33aa 100755 --- a/knewsticker-scripts/sportscores.py +++ b/knewsticker-scripts/sportscores.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -import string, urllib, sys +import string, urllib.request, urllib.parse, urllib.error, sys if len(sys.argv) > 1: sport = sys.argv[1] @@ -8,21 +8,21 @@ else: class SportsParser: def __init__(self): - print "" - print "" - print "" - print "%s" %self.title() - print "%s" %self.description() - print "%s" %self.link() - print "" + print("") + print("") + print("") + print("%s" %self.title()) + print("%s" %self.description()) + print("%s" %self.link()) + print("") self.processScores(self.inputFile()) - print "" + print("") def processScores(self, inputFile): try: - input = urllib.urlopen(self.inputFile()) + input = urllib.request.urlopen(self.inputFile()) lines = input.readlines() except: sys.exit(5) @@ -32,10 +32,10 @@ class SportsParser: self.handleScoreLine(line) def handleGame(self, headline, link): - print "" - print "%s" %headline - print "%s" %link - print "" + print("") + print("%s" %headline) + print("%s" %link) + print("") class NHLParser(SportsParser): def isScoreLine(self, line): @@ -235,7 +235,7 @@ try: parser = globals()["%sParser" %(sport)]() except: - print "Invalid sport type '%s' selected." %sport + print("Invalid sport type '%s' selected." %sport) sys.exit(2) sys.exit(0) -- cgit v1.2.1