From c44b1dcd6af127d81c45b30f953257a9d45ac91a Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Sun, 2 Sep 2012 23:48:47 +1200 Subject: [PATCH] Moved haste() to util/web --- plugins/util/execute.py | 11 ++--------- plugins/util/web.py | 10 +++++++++- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/plugins/util/execute.py b/plugins/util/execute.py index 8a9e908..9eb2321 100644 --- a/plugins/util/execute.py +++ b/plugins/util/execute.py @@ -1,14 +1,7 @@ -import http +import http, web import json, urllib2, sys -def haste(data): - URL = "http://paste.dmptr.com" - request = urllib2.Request(URL + "/documents", data) - response = urllib2.urlopen(request) - return("%s/%s" % (URL, json.loads(response.read())['key'])) - - def eval_py(code, paste_multiline=True): while True: output = http.get("http://eval.appspot.com/eval", statement=code).rstrip('\n') @@ -23,6 +16,6 @@ def eval_py(code, paste_multiline=True): status = "Code executed sucessfully: " if "\n" in output and paste_multiline: - return status + haste(output) + return status + web.haste(output) else: return output \ No newline at end of file diff --git a/plugins/util/web.py b/plugins/util/web.py index 7651ac4..65d5227 100755 --- a/plugins/util/web.py +++ b/plugins/util/web.py @@ -1,6 +1,7 @@ """ web.py - handy functions for web services """ import http, urlnorm +import json, urllib2 from urllib import urlencode @@ -28,4 +29,11 @@ def isgd(url): """ shortens a URL with the is.gd PAI """ url = urlnorm.normalize(url.encode('utf-8')) params = urlencode({'format': 'simple', 'url': url}) - return http.get("http://is.gd/create.php?%s" % params) \ No newline at end of file + return http.get("http://is.gd/create.php?%s" % params) + + +def haste(data): + URL = "http://paste.dmptr.com" + request = urllib2.Request(URL + "/documents", data) + response = urllib2.urlopen(request) + return("%s/%s" % (URL, json.loads(response.read())['key'])) \ No newline at end of file