summaryrefslogtreecommitdiffstats
path: root/knewsticker-scripts
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2023-01-14 16:34:44 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2023-01-15 10:25:12 +0900
commit900386ad4615a3dbbc04501ef24c5a43385c6078 (patch)
treee7c547f76f2100bd99be8962fe7a07c1a64d1c34 /knewsticker-scripts
parent8293cbe18989cabc30375754087091a53a78b3ee (diff)
downloadtdeaddons-900386ad4615a3dbbc04501ef24c5a43385c6078.tar.gz
tdeaddons-900386ad4615a3dbbc04501ef24c5a43385c6078.zip
Drop python2 support.r14.1.0
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'knewsticker-scripts')
-rwxr-xr-xknewsticker-scripts/fyensget.py18
-rwxr-xr-xknewsticker-scripts/sportscores.py34
2 files changed, 26 insertions, 26 deletions
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("<a href=\"([^\"]*)\" target=\"Indhold\" class=\"Overskrift.\">(.*?)</a><br>")
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("<a href=\"([^\"]*)\" class=\"Overskrift.\">(.*?)</a>")
line = FILE.readline()
while line:
match = REG.search(line)
if match:
- print "<item>\n\t<title>" + title + ": " +match.group(2) + "</title>"
- print "\t<link>"+articleBase+match.group(1)+"</link>\n</item>"
+ print("<item>\n\t<title>" + title + ": " +match.group(2) + "</title>")
+ print("\t<link>"+articleBase+match.group(1)+"</link>\n</item>")
line=FILE.readline()
################################################################################
# Print Header
################################################################################
-print """<?xml version="1.0" encoding="ISO-8859-1"?>
+print("""<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN"
"http://my.netscape.com/publish/formats/rss-0.91.dtd">
<rss version="0.91">
@@ -68,7 +68,7 @@ print """<?xml version="1.0" encoding="ISO-8859-1"?>
<language>dk</language>
<link>http://www.fyens.dk/</link>
<description>Fyens Stiftstidende</description>
-"""
+""")
################################################################################
# Main
@@ -81,8 +81,8 @@ for (url, title) in l:
################################################################################
# Print footer.
################################################################################
-print """
+print("""
</channel>
</rss>
-"""
+""")
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 "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>"
- print "<rdf:RDF"
- print "xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\""
- print "xmlns=\"http://my.netscape.com/rdf/simple/0.9/\">"
- print "<channel>"
- print "<title>%s</title>" %self.title()
- print "<description>%s</description>" %self.description()
- print "<link>%s</link>" %self.link()
- print "</channel>"
+ print("<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>")
+ print("<rdf:RDF")
+ print("xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"")
+ print("xmlns=\"http://my.netscape.com/rdf/simple/0.9/\">")
+ print("<channel>")
+ print("<title>%s</title>" %self.title())
+ print("<description>%s</description>" %self.description())
+ print("<link>%s</link>" %self.link())
+ print("</channel>")
self.processScores(self.inputFile())
- print "</rdf:RDF>"
+ print("</rdf:RDF>")
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 "<item>"
- print "<title>%s</title>" %headline
- print "<link>%s</link>" %link
- print "</item>"
+ print("<item>")
+ print("<title>%s</title>" %headline)
+ print("<link>%s</link>" %link)
+ print("</item>")
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)