diff options
author | Alexis Hildebrandt <afh@surryhill.net> | 2023-12-05 06:47:34 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-05 06:47:34 +0000 |
commit | 14db8c8f10377607c85a7fe449af8001a64f088e (patch) | |
tree | 83d4e03e3790bb3c1e8ff94d78f83494c780ea71 /contrib/getquote-uk.py | |
parent | 88e6591b09c84ea8ecd5a576e6c9c5dbe565819a (diff) | |
parent | 2a452853224e3a9a8a516c5e5b105b2738b6912f (diff) | |
download | fork-ledger-14db8c8f10377607c85a7fe449af8001a64f088e.tar.gz fork-ledger-14db8c8f10377607c85a7fe449af8001a64f088e.tar.bz2 fork-ledger-14db8c8f10377607c85a7fe449af8001a64f088e.zip |
Merge pull request #2308 from afh/migrate-py-scripts
Migrate python scripts
Diffstat (limited to 'contrib/getquote-uk.py')
-rwxr-xr-x | contrib/getquote-uk.py | 13 |
1 files changed, 7 insertions, 6 deletions
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 |