A dash of PEP-8

This commit is contained in:
Luke Rogers 2014-02-13 14:34:50 +13:00
parent 398b34fad5
commit 6cc7554cd8
11 changed files with 34 additions and 35 deletions

View file

@ -35,7 +35,8 @@ exchanges = {
@hook.command("btc", autohelp=False) @hook.command("btc", autohelp=False)
@hook.command(autohelp=False) @hook.command(autohelp=False)
def bitcoin(inp): def bitcoin(inp):
"""bitcoin <exchange> -- Gets current exchange rate for bitcoins from several exchanges, default is Blockchain. Supports MtGox, Bitpay, Coinbase and BitStamp.""" """bitcoin <exchange> -- Gets current exchange rate for bitcoins from several exchanges, default is Blockchain.
Supports MtGox, Bitpay, Coinbase and BitStamp."""
inp = inp.lower() inp = inp.lower()
if inp: if inp:

View file

@ -49,7 +49,7 @@ def dice(inp):
spec = whitespace_re.sub('', inp) spec = whitespace_re.sub('', inp)
if not valid_diceroll_re.match(spec): if not valid_diceroll_re.match(spec):
return "Invalid diceroll" return "Invalid dice roll"
groups = sign_re.findall(spec) groups = sign_re.findall(spec)
total = 0 total = 0
@ -73,13 +73,13 @@ def dice(inp):
side = int(side) side = int(side)
try: try:
if count > 0: if count > 0:
dice = nrolls(count, side) d = nrolls(count, side)
rolls += map(str, dice) rolls += map(str, d)
total += sum(dice) total += sum(d)
else: else:
dice = nrolls(-count, side) d = nrolls(-count, side)
rolls += [str(-x) for x in dice] rolls += [str(-x) for x in d]
total -= sum(dice) total -= sum(d)
except OverflowError: except OverflowError:
return "Thanks for overflowing a float, jerk >:[" return "Thanks for overflowing a float, jerk >:["

View file

@ -9,7 +9,7 @@ def domainr(inp):
except (http.URLError, http.HTTPError) as e: except (http.URLError, http.HTTPError) as e:
return "Unable to get data for some reason. Try again later." return "Unable to get data for some reason. Try again later."
if data['query'] == "": if data['query'] == "":
return "An error occurrred: {status} - {message}".format(**data['error']) return "An error occurred: {status} - {message}".format(**data['error'])
domains = "" domains = ""
for domain in data['results']: for domain in data['results']:
domains += ("\x034" if domain['availability'] == "taken" else ( domains += ("\x034" if domain['availability'] == "taken" else (

View file

@ -13,7 +13,7 @@ with open("plugins/data/8ball_responses.txt") as f:
@hook.command('8ball') @hook.command('8ball')
def eightball(input, action=None): def eightball(inp, action=None):
"""8ball <question> -- The all knowing magic eight ball, """8ball <question> -- The all knowing magic eight ball,
in electronic form. Ask and it shall be answered!""" in electronic form. Ask and it shall be answered!"""

View file

@ -1,4 +1,3 @@
# Plugin by Lukeroge
from util import hook, text, textgen from util import hook, text, textgen
import json import json
import os import os
@ -15,8 +14,8 @@ def get_generator(_json):
@hook.command(autohelp=False) @hook.command(autohelp=False)
def namegen(inp, notice=None): def namegen(inp, notice=None):
"namegen [generator] -- Generates some names using the chosen generator. " \ """namegen [generator] -- Generates some names using the chosen generator.
"'namegen list' will display a list of all generators." 'namegen list' will display a list of all generators."""
# clean up the input # clean up the input
inp = inp.strip().lower() inp = inp.strip().lower()

View file

@ -46,7 +46,7 @@ def format_item(item, show_url=True):
if item["IsShellShockerItem"]: if item["IsShellShockerItem"]:
tags.append("\x02SHELL SHOCKER®\x02") tags.append("\x02SHELL SHOCKER®\x02")
# join all the tags together in a comma seperated string ("tag1, tag2, tag3") # join all the tags together in a comma separated string ("tag1, tag2, tag3")
tag_text = u", ".join(tags) tag_text = u", ".join(tags)
if show_url: if show_url:
@ -81,7 +81,7 @@ def newegg(inp):
# submit the search request # submit the search request
r = http.get_json( r = http.get_json(
'http://www.ows.newegg.com/Search.egg/Advanced', 'http://www.ows.newegg.com/Search.egg/Advanced',
post_data = json.dumps(request) post_data=json.dumps(request)
) )
# get the first result # get the first result

View file

@ -39,10 +39,10 @@ def password(inp, notice=None):
if not okay: if not okay:
okay = okay + list(string.ascii_lowercase) okay = okay + list(string.ascii_lowercase)
password = "" pw = ""
# generates password # generates password
for x in range(length): for x in range(length):
password = password + random.choice(okay) pw = pw + random.choice(okay)
notice(password) notice(pw)

View file

@ -5,7 +5,7 @@ import datetime
@hook.command("scene") @hook.command("scene")
@hook.command @hook.command
def pre(inp): def pre(inp):
'pre <query> -- searches scene releases using orlydb.com' """pre <query> -- searches scene releases using orlydb.com"""
try: try:
h = http.get_html("http://orlydb.com/", q=inp) h = http.get_html("http://orlydb.com/", q=inp)

View file

@ -52,7 +52,7 @@ def reddit(inp):
data = data["data"]["children"] data = data["data"]["children"]
# get the requested/random post # get the requested/random post
if id_num != None: if id_num is not None:
try: try:
item = data[id_num]["data"] item = data[id_num]["data"]
except IndexError: except IndexError:
@ -64,14 +64,14 @@ def reddit(inp):
item["title"] = text.truncate_str(item["title"], 50) item["title"] = text.truncate_str(item["title"], 50)
item["link"] = short_url.format(item["id"]) item["link"] = short_url.format(item["id"])
rawtime = datetime.fromtimestamp(int(item["created_utc"])) raw_time = datetime.fromtimestamp(int(item["created_utc"]))
item["timesince"] = timesince.timesince(rawtime) item["timesince"] = timesince.timesince(raw_time)
if item["over_18"]: if item["over_18"]:
item["warning"] = " \x02NSFW\x02" item["warning"] = " \x02NSFW\x02"
else: else:
item["warning"] = "" item["warning"] = ""
return u'\x02{title} : {subreddit}\x02 - posted by \x02{author}\x02' \ return u"\x02{title} : {subreddit}\x02 - posted by \x02{author}\x02" \
' {timesince} ago - {ups} upvotes, {downs} downvotes -' \ " {timesince} ago - {ups} upvotes, {downs} downvotes -" \
' {link}{warning}'.format(**item) " {link}{warning}".format(**item)

View file

@ -9,7 +9,6 @@ from util import hook, http, text, web
@hook.command @hook.command
def wolframalpha(inp, bot=None): def wolframalpha(inp, bot=None):
"""wa <query> -- Computes <query> using Wolfram Alpha.""" """wa <query> -- Computes <query> using Wolfram Alpha."""
api_key = bot.config.get("api_keys", {}).get("wolframalpha", None) api_key = bot.config.get("api_keys", {}).get("wolframalpha", None)
if not api_key: if not api_key: