diff --git a/plugins/drama.py b/plugins/drama.py index 446ee77..ff7711b 100755 --- a/plugins/drama.py +++ b/plugins/drama.py @@ -13,7 +13,7 @@ ed_url = "http://encyclopediadramatica.com/" ua_header = ('User-Agent','Skybot/1.0 http://bitbucket.org/Scaevolus/skybot/') -@hook.command('ed') +@hook.command('ed') @hook.command def drama(inp): '''.drama -- gets first paragraph of Encyclopedia Dramatica ''' \ diff --git a/plugins/mem.py b/plugins/mem.py index f80cefa..7f0de87 100644 --- a/plugins/mem.py +++ b/plugins/mem.py @@ -26,5 +26,3 @@ def mem(inp): return 'memory usage: %d kB' % total return mem.__doc__ - -print mem('') diff --git a/plugins/misc.py b/plugins/misc.py index f628ad5..873edca 100644 --- a/plugins/misc.py +++ b/plugins/misc.py @@ -32,4 +32,4 @@ def onjoin(paraml, conn=None): for channel in conn.channels: conn.join(channel) - time.sleep(1) # don't flood JOINs + time.sleep(1) # don't flood JOINs diff --git a/plugins/regular.py b/plugins/regular.py index d6d5565..511c350 100644 --- a/plugins/regular.py +++ b/plugins/regular.py @@ -1,23 +1,23 @@ -''' -regular.py - -skybot plugin for testing regular expressions -by Ipsum -''' - -import re - -from util import hook - - -@hook.command('re') +''' +regular.py + +skybot plugin for testing regular expressions +by Ipsum +''' + +import re + +from util import hook + + +@hook.command('re') def reg(inp): ".re -- matches regular expression in given "\ "(leave 2 spaces between)" - - query = inp.split(" ", 1) - + + query = inp.split(" ", 1) + if not inp or len(query) != 2: return reg.__doc__ - return '|'.join(re.findall(query[0], query[1])) + return '|'.join(re.findall(query[0], query[1])) diff --git a/plugins/util/urlnorm.py b/plugins/util/urlnorm.py index 7b919ba..a51a76e 100644 --- a/plugins/util/urlnorm.py +++ b/plugins/util/urlnorm.py @@ -59,7 +59,7 @@ def normalize(url): fragment=quote(clean(fragment), "~") # note care must be taken to only encode & and = characters as values - query="&".join(["=".join([quote(clean(t) , "~:/?#[]@!$'()*+,;=") + query="&".join(["=".join([quote(clean(t), "~:/?#[]@!$'()*+,;=") for t in q.split("=", 1)]) for q in query.split("&")]) # Prevent dot-segments appearing in non-relative URI paths. diff --git a/plugins/validate.py b/plugins/validate.py index f2572a7..f61d1ca 100644 --- a/plugins/validate.py +++ b/plugins/validate.py @@ -1,35 +1,35 @@ -''' -Runs a given url through the w3c validator and queries - the result header for information - -by Vladi -''' - -import urllib - -from util import hook - -path = 'http://validator.w3.org/check?uri=%s' - -@hook.command('val') -@hook.command -def validate(inp): - '''.val/.validate -- runs url through the w3c markup validator''' - - if not inp: - return validate.__doc__ - - if not inp.startswith('http://'): - inp = 'http://' + inp - - url = path % (urllib.quote(inp)) - temp = urllib.urlopen(url).info() - - status = temp.getheader('X-W3C-Validator-Status') - if (status == "Valid" or status == "Invalid"): - errorcount = temp.getheader('X-W3C-Validator-Errors') - warningcount = temp.getheader('X-W3C-Validator-Warnings') - return "%s was validated as %s with %s errors and %s warnings. See: %s" \ - % (inp, status.lower(), errorcount, warningcount, url) - else: - return "Something went wrong while validating %s" % (inp) \ No newline at end of file +''' +Runs a given url through the w3c validator + +by Vladi +''' + +import urllib +import urllib2 + +from util import hook + + +@hook.command('val') +@hook.command +def validate(inp): + '''.val/.validate -- runs url through the w3c markup validator''' + + if not inp: + return validate.__doc__ + + if not inp.startswith('http://'): + inp = 'http://' + inp + + url = 'http://validator.w3.org/check?uri=%s' % urllib.quote(inp, '') + info = dict(urllib2.urlopen(url).info()) + + print info + status = info['x-w3c-validator-status'].lower() + if status in ("valid", "invalid"): + errorcount = info['x-w3c-validator-errors'] + warningcount = info['x-w3c-validator-warnings'] + return "%s was found to be %s with %s errors and %s warnings." \ + " see: %s" % (inp, status, errorcount, warningcount, url) + else: + return "Something went wrong while validating %s" % inp