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,7 +7,11 @@ from irc3.utils import IrcString
from . import Plugin from . import Plugin
def __currency(name, prefix=None, suffix=None):
class Coins(Plugin):
API_URL = 'https://api.cryptowat.ch/markets/{market}/{crypto}{currency}/summary'
def __currency(name, prefix=None, suffix=None):
def str(value): def str(value):
return '{prefix}{value:,.2f}{suffix}'.format( return '{prefix}{value:,.2f}{suffix}'.format(
prefix=prefix or '', prefix=prefix or '',
@ -15,8 +19,6 @@ def __currency(name, prefix=None, suffix=None):
value=value) value=value)
return str return str
class Coins(Plugin):
API_URL = 'https://api.cryptowat.ch/markets/{market}/{crypto}{currency}/summary'
CURRENCIES = { CURRENCIES = {
'usd': __currency('usd', prefix='$'), 'usd': __currency('usd', prefix='$'),
'eur': __currency('eur', suffix=''), 'eur': __currency('eur', suffix=''),