Use ISO currency names in ECB --symbols output.

This commit is contained in:
Chris Berkhout 2021-05-24 20:51:32 +02:00
parent d26ba68f2c
commit 80edd6fa02

View file

@ -1,9 +1,10 @@
from datetime import datetime, timedelta from datetime import datetime, timedelta
from decimal import Decimal from decimal import Decimal
from lxml import etree
import requests import requests
from lxml import etree
from pricehist import isocurrencies
from pricehist.price import Price from pricehist.price import Price
@ -33,7 +34,8 @@ class ECB:
root = etree.fromstring(data) root = etree.fromstring(data)
nodes = root.cssselect("[currency]") nodes = root.cssselect("[currency]")
currencies = sorted(set([n.attrib["currency"] for n in nodes])) currencies = sorted(set([n.attrib["currency"] for n in nodes]))
pairs = [f"EUR/{c}" for c in currencies] iso = isocurrencies.bycode()
pairs = [f"EUR/{c} Euro against {iso[c].name}" for c in currencies]
return pairs return pairs
def fetch(self, pair, type, start, end): def fetch(self, pair, type, start, end):