Move __currency into Coins class

This commit is contained in:
Nils Schweinsberg 2017-10-15 03:37:49 +02:00
parent 180825dfe1
commit ddf1d18a92

View File

@ -7,16 +7,18 @@ from irc3.utils import IrcString
from . import Plugin from . import Plugin
def __currency(name, prefix=None, suffix=None):
def str(value):
return '{prefix}{value:,.2f}{suffix}'.format(
prefix=prefix or '',
suffix=suffix or ('' if (prefix or suffix) else (' ' + name)),
value=value)
return str
class Coins(Plugin): class Coins(Plugin):
API_URL = 'https://api.cryptowat.ch/markets/{market}/{crypto}{currency}/summary' API_URL = 'https://api.cryptowat.ch/markets/{market}/{crypto}{currency}/summary'
def __currency(name, prefix=None, suffix=None):
def str(value):
return '{prefix}{value:,.2f}{suffix}'.format(
prefix=prefix or '',
suffix=suffix or ('' if (prefix or suffix) else (' ' + name)),
value=value)
return str
CURRENCIES = { CURRENCIES = {
'usd': __currency('usd', prefix='$'), 'usd': __currency('usd', prefix='$'),
'eur': __currency('eur', suffix=''), 'eur': __currency('eur', suffix=''),