a bunch of things

This commit is contained in:
Luke Rogers 2013-12-01 20:44:04 +13:00
parent 8317ba0920
commit 3e073c8278
2 changed files with 9 additions and 12 deletions

View File

@ -14,11 +14,11 @@ def spell(inp):
return "Could not find dictionary: {}".format(locale)
if len(inp.split(" ")) > 1:
# input is a sentence
chkr = SpellChecker(locale)
chkr.set_text(inp)
offset = 0
for err in chkr:
# find the location of the incorrect word
start = err.wordpos + offset
@ -31,9 +31,9 @@ def spell(inp):
offset = (offset + len(s_string)) - len(err.word)
# replace the word with the suggestions
inp = inp[:start] + s_string + inp[finish:]
return inp
else:
# input is a word
dictionary = enchant.Dict(locale)
is_correct = dictionary.check(inp)
suggestions = dictionary.suggest(inp)

View File

@ -1,6 +1,4 @@
import random
from util import hook, http, web
from util import hook, web
@hook.command
@ -13,7 +11,7 @@ def stock(inp):
# if we dont get a company name back, the symbol doesn't match a company
if quote['Change'] is None:
return "unknown ticker symbol %s" % inp
return "Unknown ticker symbol: {}".format(sym)
change = float(quote['Change'])
price = float(quote['LastTradePriceOnly'])
@ -24,10 +22,9 @@ def stock(inp):
quote['color'] = "3"
quote['PercentChange'] = 100 * change / (price - change)
print quote
ret = "\x02%(Name)s\x02 (\x02%(symbol)s\x02) - %(LastTradePriceOnly)s " \
"\x03%(color)s%(Change)s (%(PercentChange).2f%%)\x03 " \
"Day Range: %(DaysRange)s " \
"MCAP: %(MarketCapitalization)s" % quote
return ret
return u"\x02{Name}\x02 (\x02{symbol}\x02) - {LastTradePriceOnly} " \
"\x03{color}{Change} ({PercentChange:.2f}%)\x03 " \
"Day Range: {DaysRange} " \
"MCAP: {MarketCapitalization}".format(**quote)