Fixed formatting.
This commit is contained in:
parent
146ae3c279
commit
4069dd21a3
89 changed files with 615 additions and 496 deletions
|
@ -4,9 +4,10 @@ import json
|
|||
|
||||
url = 'http://www.google.com/ig/api'
|
||||
|
||||
|
||||
@hook.command
|
||||
def stock(inp):
|
||||
"stock <symbol> -- Gets information about stock symbol <symbol>."
|
||||
"""stock <symbol> -- Gets information about stock symbol <symbol>."""
|
||||
|
||||
parsed = http.get_xml(url, stock=inp)
|
||||
|
||||
|
@ -19,25 +20,26 @@ def stock(inp):
|
|||
|
||||
# if we dont get a company name back, the symbol doesn't match a company
|
||||
if not "company" in results:
|
||||
guess_data = json.loads(http.get("http://d.yimg.com/autoc.finance.yahoo.com/autoc", query=inp, callback="YAHOO.Finance.SymbolSuggest.ssCallback")[39:-1])
|
||||
guess_data = json.loads(http.get("http://d.yimg.com/autoc.finance.yahoo.com/autoc", query=inp,
|
||||
callback="YAHOO.Finance.SymbolSuggest.ssCallback")[39:-1])
|
||||
guess = guess_data['ResultSet']['Result']
|
||||
if len(guess) > 0:
|
||||
guess = guess[0]["symbol"]
|
||||
return stock(guess)
|
||||
else:
|
||||
return "error: unable to get stock info for '%s'" % inp
|
||||
|
||||
|
||||
if results['last'] == '0.00':
|
||||
return "%(company)s - last known stock value was 0.00 %(currency)s" \
|
||||
" as of %(trade_timestamp)s" % (results)
|
||||
" as of %(trade_timestamp)s" % results
|
||||
|
||||
if results['change'][0] == '-':
|
||||
results['color'] = "5"
|
||||
else:
|
||||
results['color'] = "3"
|
||||
|
||||
ret = "%(company)s - %(last)s %(currency)s " \
|
||||
"\x03%(color)s%(change)s (%(perc_change)s%%)\x03 " \
|
||||
ret = "%(company)s - %(last)s %(currency)s " \
|
||||
"\x03%(color)s%(change)s (%(perc_change)s%%)\x03 " \
|
||||
"as of %(trade_timestamp)s" % results
|
||||
|
||||
if results['delay'] != '0':
|
||||
|
|
Reference in a new issue