Skip to content

Commit

Permalink
Use HTTPS to access World Bank SDMX endpoints
Browse files Browse the repository at this point in the history
Work around khaeru/sdmx#191
  • Loading branch information
khaeru committed Sep 1, 2024
1 parent 3181e11 commit d07bcd2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions message_ix_models/tools/wb.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,12 @@ def get_weight(code: "sdmx.model.common.Code") -> float:
return 1.0

elif method == "population":
# Work around khaeru/sdmx#191: ensure the HTTPS URL is used
client = sdmx.Client("WB_WDI")
client.source.url = client.source.url.replace("http://", "https://")

# Retrieve WB_WDI data for SERIES=SP_POP_TOTAL (Population, total)
dm = sdmx.Client("WB_WDI").data(
dm = client.data(
"WDI", key="A.SP_POP_TOTL.", params=dict(startPeriod=2020, endPeriod=2020)
)

Expand Down Expand Up @@ -154,7 +158,7 @@ def fetch_codelist(id: str) -> "sdmx.model.common.Codelist":
import sdmx

file = pooch.retrieve(
url="http://api.worldbank.org/v2/sdmx/rest/codelist/WB/", known_hash=None
url="https://api.worldbank.org/v2/sdmx/rest/codelist/WB/", known_hash=None
)
# Read the retrieved SDMX StructureMessage and extract the code list
sm = sdmx.read_sdmx(file)
Expand Down

0 comments on commit d07bcd2

Please sign in to comment.