module formatting tweaks; tabs -> spaces and more

This commit is contained in:
mutantmonkey
2012-01-03 14:09:34 -05:00
parent 733d3fd39e
commit 56f116732d
32 changed files with 1307 additions and 1434 deletions

View File

@@ -10,34 +10,34 @@ http://inamidst.com/phenny/
import web
def val(phenny, input):
"""Check a webpage using the W3C Markup Validator."""
if not input.group(2):
return phenny.reply("Nothing to validate.")
uri = input.group(2)
if not uri.startswith('http://'):
uri = 'http://' + uri
"""Check a webpage using the W3C Markup Validator."""
if not input.group(2):
return phenny.reply("Nothing to validate.")
uri = input.group(2)
if not uri.startswith('http://'):
uri = 'http://' + uri
path = '/check?uri=%s;output=xml' % web.urllib.quote(uri)
info = web.head('http://validator.w3.org' + path)
path = '/check?uri=%s;output=xml' % web.urllib.quote(uri)
info = web.head('http://validator.w3.org' + path)
result = uri + ' is '
result = uri + ' is '
if isinstance(info, list):
return phenny.say('Got HTTP response %s' % info[1])
if isinstance(info, list):
return phenny.say('Got HTTP response %s' % info[1])
if 'X-W3C-Validator-Status' in info:
result += str(info['X-W3C-Validator-Status'])
if info['X-W3C-Validator-Status'] != 'Valid':
if 'X-W3C-Validator-Errors' in info:
n = int(info['X-W3C-Validator-Errors'].split(' ')[0])
if n != 1:
result += ' (%s errors)' % n
else: result += ' (%s error)' % n
else: result += 'Unvalidatable: no X-W3C-Validator-Status'
if 'X-W3C-Validator-Status' in info:
result += str(info['X-W3C-Validator-Status'])
if info['X-W3C-Validator-Status'] != 'Valid':
if 'X-W3C-Validator-Errors' in info:
n = int(info['X-W3C-Validator-Errors'].split(' ')[0])
if n != 1:
result += ' (%s errors)' % n
else: result += ' (%s error)' % n
else: result += 'Unvalidatable: no X-W3C-Validator-Status'
phenny.reply(result)
phenny.reply(result)
val.rule = (['val'], r'(?i)(\S+)')
val.example = '.val http://www.w3.org/'
if __name__ == '__main__':
print(__doc__.strip())
print(__doc__.strip())