From 8200b417c0434fd2b8e60ff31eaf59593e7f25e9 Mon Sep 17 00:00:00 2001 From: Kamil Dudka Date: Mon, 28 May 2018 14:24:33 +0200 Subject: [PATCH] Resolves: #1574835 - make units_cur work again --- 0001-units-2.16-units_cur.patch | 80 +++++++++++++++++++++++++++++++++ units.spec | 10 ++++- 2 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 0001-units-2.16-units_cur.patch diff --git a/0001-units-2.16-units_cur.patch b/0001-units-2.16-units_cur.patch new file mode 100644 index 0000000..101a396 --- /dev/null +++ b/0001-units-2.16-units_cur.patch @@ -0,0 +1,80 @@ +From 29b4b1ac90bfe54f1d7d83a3b3e4e1a1305332fa Mon Sep 17 00:00:00 2001 +From: Kamil Dudka +Date: Mon, 28 May 2018 14:21:35 +0200 +Subject: [PATCH] Resolves: #1574835 - make units_cur work again + +--- + units_cur | 44 ++++++++++++++++++++++++++------------------ + 1 file changed, 26 insertions(+), 18 deletions(-) + +diff --git a/units_cur b/units_cur +index 5541355..d00c12c 100755 +--- a/units_cur ++++ b/units_cur +@@ -5,14 +5,17 @@ from __future__ import absolute_import, division, print_function + # + # + +-version = '4.1' ++version = '4.2' + +-# 30 October 2017 ++# Version 4.2: 18 April 2018 ++# ++# Handle case of empty/malformed entry returned from the server ++# ++# Version 4.1: 30 October 2017 + # + # Fixed to include USD in the list of currency codes. + # +-# Version 4 +-# 2 October 2017 ++# Version 4: 2 October 2017 + # + # Complete rewrite to use Yahoo YQL API due to removal of TimeGenie RSS feed. + # Switched to requests library using JSON. One program now runs under +@@ -258,22 +261,27 @@ except requests.exceptions.RequestException as e: + format(e)) + exit(1) + +-rates = [ data['resource']['fields']['price'] for data in webdata] +-codes = [ data['resource']['fields']['symbol'][0:3] for data in webdata] + + rate_index = 1 +- +-for (code,rate) in zip(codes,rates): +- if code not in currency.keys(): +- if (verbose): +- stderr.write('Got unknown currency with code {}\n'.format(code)) +- else: +- if not currency[code][rate_index]: +- currency[code][rate_index] = '1|{} US$'.format(rate) +- elif verbose: +- stderr.write('Got value "{}" for currency "{}" but ' +- 'it is already defined\n'.format(rate, code)) +- ++for data in webdata: ++ entry = data['resource']['fields'] ++ if 'price' not in entry or 'symbol' not in entry: # Skip empty/bad entries ++ if verbose: ++ stderr.write('Got bad entry from server: '+str(entry)+'\n') ++ else: ++ rate = entry['price'] ++ code = entry['symbol'][0:3] ++ if code not in currency.keys(): ++ if (verbose): ++ stderr.write('Got unknown currency with code {}\n'.format(code)) ++ else: ++ if not currency[code][rate_index]: ++ currency[code][rate_index] = '1|{} US$'.format(rate) ++ elif verbose: ++ stderr.write('Got value "{}" for currency "{}" but ' ++ 'it is already defined\n'.format(rate, code)) ++ ++ + # Delete currencies where we have no rate data + for code in currency.keys(): + if not currency[code][rate_index]: +-- +2.14.3 + diff --git a/units.spec b/units.spec index 3cb9f67..9878896 100644 --- a/units.spec +++ b/units.spec @@ -1,7 +1,7 @@ Summary: A utility for converting amounts from one unit to another Name: units Version: 2.16 -Release: 4%{?dist} +Release: 5%{?dist} Source: https://ftp.gnu.org/gnu/units/%{name}-%{version}.tar.gz URL: https://www.gnu.org/software/units/units.html License: GPLv3+ @@ -17,6 +17,9 @@ BuildRequires: readline-devel # used by the units_cur script Requires: python3-unidecode +# make units_cur work again (#1574835) +Patch1: 0001-units-2.16-units_cur.patch + %description Units converts an amount from one unit to another, or tells you what mathematical operation you need to perform to convert from one unit to @@ -24,7 +27,7 @@ another. The units program can handle multiplicative scale changes as well as conversions such as Fahrenheit to Celsius. %prep -%setup -q +%autosetup -p1 # make units_cur use Python 3 sed -e 's|^AC_PATH_PROG(PYTHON, python|&3|' -i configure.ac @@ -64,6 +67,9 @@ fi %{_mandir}/man1/* %changelog +* Mon May 25 2018 Kamil Dudka - 2.16-5 +- make units_cur work again (#1574835) + * Mon Feb 19 2018 Kamil Dudka - 2.16-4 - add explicit BR for the gcc compiler