Commit 3d91ed22 authored by Benoit Fabrèges's avatar Benoit Fabrèges
Browse files

list mesocenters by region with new rst tag

parent 6bc3ac76
Pipeline #6036 passed with stages
in 53 seconds
......@@ -30,18 +30,28 @@ def json_mesolist_to_rst(url):
response = urlopen(url).read()
data = json.loads(response.decode('utf-8'))
meso_list = {}
for meso in data['mesocentreList']:
region = meso['location']
if region in meso_list:
meso_list[region].append(meso)
else:
meso_list[region] = [meso]
keys_list = ["institutesName", "financersName", "GPSCoordinates", "accessPolicy"]
rst = ""
for meso in data['mesocentreList']:
rst += f".. meso:: {meso['name']}\n"
del meso['name']
for key, val in meso.items():
if not isinstance(val, list):
rst += f"\t:{key}: {val}\n"
else:
if key in keys_list:
rst += f"\t:{key}: {', '.join(map(str, val))}\n"
for region, mesocenters in meso_list.items():
rst += f".. region:: {region}\n"
for meso in mesocenters:
rst += f"\t.. meso:: {meso['name']}\n"
del meso['name']
for key, val in meso.items():
if not isinstance(val, list):
rst += f"\t\t:{key}: {val}\n"
else:
if key in keys_list:
rst += f"\t\t:{key}: {', '.join(map(str, val))}\n"
print(rst)
#return rst
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment