PEP-8, tweaks to .time and a new library (soon to be expanded)
This commit is contained in:
parent
e959c27d66
commit
a9927eca90
2 changed files with 14 additions and 6 deletions
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
from util import hook
|
from util import hook
|
||||||
from util import http
|
from util import http
|
||||||
|
from util.formatting import capitalize_first
|
||||||
|
|
||||||
api_url = 'http://api.wolframalpha.com/v2/query?format=plaintext'
|
api_url = 'http://api.wolframalpha.com/v2/query?format=plaintext'
|
||||||
|
|
||||||
|
@ -25,15 +26,15 @@ def time_command(inp, bot=None):
|
||||||
if inp.lower() == "unix":
|
if inp.lower() == "unix":
|
||||||
place = "Unix Epoch"
|
place = "Unix Epoch"
|
||||||
else:
|
else:
|
||||||
place = " ".join(request.xpath("//pod[@title='Input interpretation']/" \
|
place = capitalize_first(" ".join(request.xpath("//pod[@title='Input" \
|
||||||
"subpod/plaintext/text()"))[16:].title()
|
" interpretation']/subpod/plaintext/text()"))[16:])
|
||||||
|
|
||||||
if time:
|
if time:
|
||||||
# if wolfram alpha had to guess a place, then show the place it chose
|
# if wolfram alpha had to guess a place, then show the place it chose
|
||||||
#if request.xpath("//assumptions"):
|
#if request.xpath("//assumptions"):
|
||||||
# return "%s - \x02%s\x02" % (time, place)
|
# return "%s - \x02%s\x02" % (time, place)
|
||||||
#else:
|
#else:
|
||||||
# return time
|
# return time
|
||||||
return "%s - \x02%s\x02" % (time, place)
|
return "%s - \x02%s\x02" % (time, place)
|
||||||
else:
|
else:
|
||||||
return "Could not get the time for '%s'" % inp
|
return "Could not get the time for '%s'" % inp
|
||||||
|
|
7
plugins/util/formatting.py
Executable file
7
plugins/util/formatting.py
Executable file
|
@ -0,0 +1,7 @@
|
||||||
|
""" formatting.py - handy functions for formatting text """
|
||||||
|
|
||||||
|
def capitalize_first(line):
|
||||||
|
""" capitalises the first letter of words
|
||||||
|
(keeps other letters intact)
|
||||||
|
"""
|
||||||
|
return ' '.join([s[0].upper() + s[1:] for s in line.split(' ')])
|
Reference in a new issue