diff options
| author | Dalf <alex@al-f.net> | 2020-08-06 17:42:46 +0200 |
|---|---|---|
| committer | Alexandre Flament <alex@al-f.net> | 2020-09-10 10:39:04 +0200 |
| commit | 1022228d950c2a809ed613df1a515d9a6cafda7c (patch) | |
| tree | d792dddea1a5b278b018ed4e024cd13340d5c1b1 /utils/fetch_currencies.py | |
| parent | 272158944bf13503e2597018fc60a00baddec660 (diff) | |
Drop Python 2 (1/n): remove unicode string and url_utils
Diffstat (limited to 'utils/fetch_currencies.py')
| -rw-r--r-- | utils/fetch_currencies.py | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/utils/fetch_currencies.py b/utils/fetch_currencies.py index 5605fb387..437c375db 100644 --- a/utils/fetch_currencies.py +++ b/utils/fetch_currencies.py @@ -1,11 +1,11 @@ # -*- coding: utf-8 -*- -from __future__ import print_function + import json import re import unicodedata import string -from urllib import urlencode +from urllib.parse import urlencode from requests import get languages = {'de', 'en', 'es', 'fr', 'hu', 'it', 'nl', 'jp'} @@ -39,7 +39,7 @@ def add_currency_name(name, iso4217): db_names = db['names'] - if not isinstance(iso4217, basestring): + if not isinstance(iso4217, str): print("problem", name, iso4217) return @@ -126,7 +126,7 @@ def wdq_query(query): url = url_wmflabs_template + query htmlresponse = get(url) jsonresponse = json.loads(htmlresponse.content) - qlist = map(add_q, jsonresponse.get('items', {})) + qlist = list(map(add_q, jsonresponse.get('items', {}))) error = jsonresponse.get('status', {}).get('error', None) if error is not None and error != 'OK': print("error for query '" + query + "' :" + error) @@ -150,12 +150,12 @@ for q in wmflabs_queries: wdq_query(q) # static -add_currency_name(u"euro", 'EUR') -add_currency_name(u"euros", 'EUR') -add_currency_name(u"dollar", 'USD') -add_currency_name(u"dollars", 'USD') -add_currency_name(u"peso", 'MXN') -add_currency_name(u"pesos", 'MXN') +add_currency_name("euro", 'EUR') +add_currency_name("euros", 'EUR') +add_currency_name("dollar", 'USD') +add_currency_name("dollars", 'USD') +add_currency_name("peso", 'MXN') +add_currency_name("pesos", 'MXN') # write f = open("currencies.json", "wb") |