Fix __currency

This commit is contained in:
Nils Schweinsberg 2017-10-15 03:34:23 +02:00
parent f1452c7e2a
commit 180825dfe1

View File

@ -6,21 +6,23 @@ from irc3.utils import IrcString
from . import Plugin
def __currency(name=None, prefix=None, suffix=None):
return lambda value:
def __currency(name, prefix=None, suffix=None):
def str(value):
return '{prefix}{value:,.2f}{suffix}'.format(
prefix=prefix or '',
suffix=suffix or (' ' + name if name else ''),
suffix=suffix or ('' if (prefix or suffix) else (' ' + name)),
value=value)
return str
class Coins(Plugin):
API_URL = 'https://api.cryptowat.ch/markets/{market}/{crypto}{currency}/summary'
CURRENCIES = {
'usd': __currency(prefix='$'),
'eur': __currency(suffix=''),
'eth': __currency(suffix='Ξ'),
'btc': __currency(suffix='฿'),
'xmr': __currency(name='xmr'),
'usd': __currency('usd', prefix='$'),
'eur': __currency('eur', suffix=''),
'eth': __currency('eth', suffix='Ξ'),
'btc': __currency('btc', suffix='฿'),
'xmr': __currency('xmr'),
}
@command