diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2013-07-25 19:26:52 +0200 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2015-12-03 03:29:37 +0100 |
commit | f3b86ed2d5bce85b3b9c27eb949cd88cf7d526bc (patch) | |
tree | a187725f5ec7f1c67d2b9a471b4000ad40a16b04 /modules/validate.py | |
parent | 4b905606692a2f147946505abe6ade1c241d1000 (diff) | |
download | bot-f3b86ed2d5bce85b3b9c27eb949cd88cf7d526bc.tar.gz bot-f3b86ed2d5bce85b3b9c27eb949cd88cf7d526bc.tar.bz2 bot-f3b86ed2d5bce85b3b9c27eb949cd88cf7d526bc.zip |
fix indentation and trailing whitespaces
Diffstat (limited to 'modules/validate.py')
-rwxr-xr-x | modules/validate.py | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/modules/validate.py b/modules/validate.py index 85815d1..ac036f5 100755 --- a/modules/validate.py +++ b/modules/validate.py @@ -9,35 +9,35 @@ 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 - - path = '/check?uri=%s;output=xml' % web.urllib.quote(uri) - info = web.head('http://validator.w3.org' + path) - - result = uri + ' is ' - - if isinstance(info, list): - return phenny.say('Got HTTP response %s' % info[1]) - - if info.has_key('X-W3C-Validator-Status'): - result += str(info['X-W3C-Validator-Status']) - if info['X-W3C-Validator-Status'] != 'Valid': - if info.has_key('X-W3C-Validator-Errors'): - 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) +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 + + path = '/check?uri=%s;output=xml' % web.urllib.quote(uri) + info = web.head('http://validator.w3.org' + path) + + result = uri + ' is ' + + if isinstance(info, list): + return phenny.say('Got HTTP response %s' % info[1]) + + if info.has_key('X-W3C-Validator-Status'): + result += str(info['X-W3C-Validator-Status']) + if info['X-W3C-Validator-Status'] != 'Valid': + if info.has_key('X-W3C-Validator-Errors'): + 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) val.rule = (['val'], r'(?i)(\S+)') val.example = '.val http://www.w3.org/' -if __name__ == '__main__': - print __doc__.strip() +if __name__ == '__main__': + print __doc__.strip() |