[modules/getcrypto] Simplify code a bit

Make codeclimate happy...
This commit is contained in:
Tobias Witek 2017-08-19 16:14:42 +02:00
parent 5e007acb5c
commit 054ad96ec2

View file

@ -21,20 +21,18 @@ import bumblebee.output
import bumblebee.engine import bumblebee.engine
from requests.exceptions import RequestException from requests.exceptions import RequestException
def getfromkrak(coin,currency): def getfromkrak(coin,currency):
if coin=='Btc': abbrev = {
epair = "xbt"+currency "Btc": ["xbt", "XXBTZ"],
tickname = "XXBTZ"+currency.upper() "Eth": ["eth", "XETHZ"],
if coin=='Eth': "Ltc": ["ltc", "XLTCZ"],
epair = "eth"+currency }
tickname = "XETHZ"+currency.upper() data = abbrev.get(coin, None)
if coin=='Ltc': if not data: return
epair = "ltc"+currency epair = "{}{}".format(data[0], currency)
tickname = "XLTCZ"+currency.upper() tickname = "{}{}".format(data[1], currency.upper())
try: try:
krakenget = requests.get('https://api.kraken.com/0/public/Ticker?pair='+epair).json() krakenget = requests.get('https://api.kraken.com/0/public/Ticker?pair='+epair).json()
except RequestException: except (RequestException, Exception):
return "No connection"
except Exception:
return "No connection" return "No connection"
kethusdask = float(krakenget['result'][tickname]['a'][0]) kethusdask = float(krakenget['result'][tickname]['a'][0])
kethusdbid = float(krakenget['result'][tickname]['b'][0]) kethusdbid = float(krakenget['result'][tickname]['b'][0])