From 3d22ddc7e67a06d0bdf2994b1ef018bc46e92f34 Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Mon, 4 Dec 2023 12:23:56 +0100 Subject: Migrate Python scripts to Python 3 --- contrib/getquote-uk.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'contrib/getquote-uk.py') diff --git a/contrib/getquote-uk.py b/contrib/getquote-uk.py index a69d4e7d..0c6c052a 100755 --- a/contrib/getquote-uk.py +++ b/contrib/getquote-uk.py @@ -1,7 +1,6 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- +#!/usr/bin/env python3 -import urllib, string, sys +import urllib, string, sys, os def download(sym): url = "http://uk.old.finance.yahoo.com/d/quotes.csv?s=" @@ -13,11 +12,13 @@ def download(sym): result = float(fields[1])/100 return result - +if len(sys.argv) == 1: + print(f'USAGE: {os.path.basename(__file__)} SYMBOL', file=sys.stderr) + sys.exit(-1) sym = sys.argv[1] sym = sym.replace('_', '.') if sym == '£': - print '£1.00' + print('£1.00') else: - try: print "£" +str(download(sym)) + try: print(f'£ {str(download(sym))}') except: pass -- cgit v1.2.3