Ricordisamoa has uploaded a new change for review.
https://gerrit.wikimedia.org/r/261800
Change subject: Switch to Python 3
......................................................................
Switch to Python 3
* urllib → urllib.parse
* urllib2 → urllib.request
* utf-8 for urlopen
* map() → list(map())
* dict.values() → list(dict.values())
Change-Id: I961c2481390d9c0880f4919557441743f4362470
---
M chemistry.py
1 file changed, 7 insertions(+), 5 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/labs/tools/ptable
refs/changes/00/261800/1
diff --git a/chemistry.py b/chemistry.py
index 91da1dd..1b51bdb 100644
--- a/chemistry.py
+++ b/chemistry.py
@@ -18,8 +18,8 @@
import json
import operator
-from urllib import urlencode
-from urllib2 import urlopen
+from urllib.parse import urlencode
+from urllib.request import urlopen
from collections import defaultdict
try:
@@ -34,7 +34,9 @@
@ttl_cache(maxsize=20, ttl=21600)
def get_json_cached(url, data):
"""The information is cached for 6 hours."""
- return json.load(urlopen(url, data))
+ with urlopen(url, data.encode('utf-8')) as response:
+ raw = response.read()
+ return json.loads(raw.decode('utf-8'))
def get_json(url, data):
@@ -146,7 +148,7 @@
continue
value = value.split('|')
if len(value) == 4:
- value = map(float, value)
+ value = list(map(float, value))
if len(set(value[:3])) == 1 and value[3] == 1 and value[0] ==
int(value[0]):
elements[item_id].number = int(value[0])
for item_id, datatype, value in wdq['props'][str(Element.symbol_pid)]:
@@ -166,7 +168,7 @@
label = None
entity = entities.get(element.item_id)
if entity and 'labels' in entity and len(entity['labels']) == 1:
- label = entity['labels'].values()[0]['value']
+ label = list(entity['labels'].values())[0]['value']
element.label = label
yield element
--
To view, visit https://gerrit.wikimedia.org/r/261800
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I961c2481390d9c0880f4919557441743f4362470
Gerrit-PatchSet: 1
Gerrit-Project: labs/tools/ptable
Gerrit-Branch: master
Gerrit-Owner: Ricordisamoa <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits