pep8 tweaks
This commit is contained in:
parent
a1eb155b14
commit
923e829068
4 changed files with 18 additions and 11 deletions
|
@ -3,8 +3,9 @@ import re
|
||||||
from util import hook, http, misc
|
from util import hook, http, misc
|
||||||
from BeautifulSoup import BeautifulSoup
|
from BeautifulSoup import BeautifulSoup
|
||||||
|
|
||||||
@hook.command("calc")
|
|
||||||
@hook.command("math")
|
@hook.command("math")
|
||||||
|
@hook.command
|
||||||
def calc(inp):
|
def calc(inp):
|
||||||
".calc <term> -- Calculate <term> with Google Calc."
|
".calc <term> -- Calculate <term> with Google Calc."
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
from util import hook
|
from util import hook
|
||||||
|
|
||||||
|
|
||||||
def find_location(ip, api):
|
def find_location(ip, api):
|
||||||
import string
|
import string
|
||||||
import urllib
|
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(";")
|
response = response.split(";")
|
||||||
give = {}
|
give = {}
|
||||||
give["country"] = response[4].title()
|
give["country"] = response[4].title()
|
||||||
|
@ -13,6 +15,7 @@ def find_location(ip, api):
|
||||||
give["timezone"] = response[10].title()
|
give["timezone"] = response[10].title()
|
||||||
return give
|
return give
|
||||||
|
|
||||||
|
|
||||||
def timezone(ip):
|
def timezone(ip):
|
||||||
time = find_location(ip)["timezone"]
|
time = find_location(ip)["timezone"]
|
||||||
time = time.replace(":", ".")
|
time = time.replace(":", ".")
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
from util import hook
|
from util import hook
|
||||||
import urllib2
|
import urllib2
|
||||||
|
|
||||||
|
|
||||||
@hook.command
|
@hook.command
|
||||||
def gitio(inp):
|
def gitio(inp):
|
||||||
".gitio <url> [code] -- Shorten Github URLs with git.io. [code] is a optional custom short code."
|
".gitio <url> [code] -- Shorten Github URLs with git.io. [code] is a optional custom short code."
|
||||||
|
@ -13,7 +14,8 @@ def gitio(inp):
|
||||||
except:
|
except:
|
||||||
code = None
|
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[:8] != "https://":
|
||||||
if url[:7] != "http://":
|
if url[:7] != "http://":
|
||||||
url = "https://" + url
|
url = "https://" + url
|
||||||
|
@ -31,7 +33,8 @@ def gitio(inp):
|
||||||
return "Failed to get URL!"
|
return "Failed to get URL!"
|
||||||
urlinfo = str(f.info())
|
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"):
|
for row in urlinfo.split("\n"):
|
||||||
if row.find("Status") != -1:
|
if row.find("Status") != -1:
|
||||||
status = row
|
status = row
|
||||||
|
|
|
@ -15,7 +15,7 @@ def gis(inp):
|
||||||
|
|
||||||
parsed = api_get('images', inp)
|
parsed = api_get('images', inp)
|
||||||
if not 200 <= parsed['responseStatus'] < 300:
|
if not 200 <= parsed['responseStatus'] < 300:
|
||||||
raise IOError('error searching for images: %d: %s' % (
|
raise IOError('error searching for images: %d: %s' % ( \
|
||||||
parsed['responseStatus'], ''))
|
parsed['responseStatus'], ''))
|
||||||
if not parsed['responseData']['results']:
|
if not parsed['responseData']['results']:
|
||||||
return 'no images found'
|
return 'no images found'
|
||||||
|
|
Reference in a new issue