From 923e829068283962294ae4224c480b728beb6910 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Tue, 13 Mar 2012 07:13:32 +1300 Subject: [PATCH] pep8 tweaks --- plugins/gcalc.py | 5 +++-- plugins/geoip.py | 5 ++++- plugins/gitio.py | 9 ++++++--- plugins/google.py | 10 +++++----- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/plugins/gcalc.py b/plugins/gcalc.py index a568f53..68333b1 100755 --- a/plugins/gcalc.py +++ b/plugins/gcalc.py @@ -3,8 +3,9 @@ import re from util import hook, http, misc from BeautifulSoup import BeautifulSoup -@hook.command("calc") + @hook.command("math") +@hook.command def calc(inp): ".calc -- Calculate with Google Calc." @@ -14,7 +15,7 @@ def calc(inp): soup = BeautifulSoup(page) - response = soup.find('h2', {'class' : 'r'}) + response = soup.find('h2', {'class': 'r'}) if response is None: return "Could not calculate " + inp diff --git a/plugins/geoip.py b/plugins/geoip.py index 97a3fc7..b8d540c 100755 --- a/plugins/geoip.py +++ b/plugins/geoip.py @@ -1,9 +1,11 @@ from util import hook + def find_location(ip, api): import string import urllib - response = urllib.urlopen("http://api.ipinfodb.com/v3/ip-city/?key="+api+"&ip="+ip).read() + response = urllib.urlopen("http://api.ipinfodb.com/v3/ip-city/?key=" \ + + api + "&ip=" + ip).read() response = response.split(";") give = {} give["country"] = response[4].title() @@ -13,6 +15,7 @@ def find_location(ip, api): give["timezone"] = response[10].title() return give + def timezone(ip): time = find_location(ip)["timezone"] time = time.replace(":", ".") diff --git a/plugins/gitio.py b/plugins/gitio.py index be40835..287eed0 100755 --- a/plugins/gitio.py +++ b/plugins/gitio.py @@ -2,6 +2,7 @@ from util import hook import urllib2 + @hook.command def gitio(inp): ".gitio [code] -- Shorten Github URLs with git.io. [code] is a optional custom short code." @@ -13,13 +14,14 @@ def gitio(inp): except: code = None - # if the first 8 chars of "url" are not "https://" then append "https://" to the url, also convert "http://" to "https://" + # if the first 8 chars of "url" are not "https://" then append + # "https://" to the url, also convert "http://" to "https://" if url[:8] != "https://": if url[:7] != "http://": url = "https://" + url else: url = "https://" + url[7:] - url='url='+str(url) + url = 'url=' + str(url) if code: url = url + '&code=' + str(code) req = urllib2.Request(url='http://git.io', data=url) @@ -31,7 +33,8 @@ def gitio(inp): return "Failed to get URL!" urlinfo = str(f.info()) - # loop over the rows in urlinfo and pick out location and status (this is pretty odd code, but urllib2.Request is weird) + # loop over the rows in urlinfo and pick out location and + # status (this is pretty odd code, but urllib2.Request is weird) for row in urlinfo.split("\n"): if row.find("Status") != -1: status = row diff --git a/plugins/google.py b/plugins/google.py index 7293099..5d6f9ac 100755 --- a/plugins/google.py +++ b/plugins/google.py @@ -15,12 +15,12 @@ def gis(inp): parsed = api_get('images', inp) if not 200 <= parsed['responseStatus'] < 300: - raise IOError('error searching for images: %d: %s' % ( - parsed['responseStatus'], '')) + raise IOError('error searching for images: %d: %s' % ( \ + parsed['responseStatus'], '')) if not parsed['responseData']['results']: return 'no images found' - return random.choice(parsed['responseData']['results'][:10])\ - ['unescapedUrl'] # squares is dumb + return random.choice(parsed['responseData']['results'][:10]) \ + ['unescapedUrl'] # squares is dumb @hook.command('g') @@ -31,7 +31,7 @@ def google(inp): parsed = api_get('web', inp) if not 200 <= parsed['responseStatus'] < 300: raise IOError('error searching for pages: %d: %s' % ( - parsed['responseStatus'], '')) + parsed['responseStatus'], '')) if not parsed['responseData']['results']: return 'No results found.'