Fix checks

This commit is contained in:
Florian Bruhin 2014-02-07 11:01:58 +01:00
parent 5b7dc1afb7
commit 940b2d0860
3 changed files with 78 additions and 76 deletions

View File

@ -32,7 +32,7 @@ import qutebrowser.utils.harfbuzz as harfbuzz
harfbuzz.fix() harfbuzz.fix()
from PyQt5.QtWidgets import QApplication, QDialog from PyQt5.QtWidgets import QApplication, QDialog
from PyQt5.QtCore import QUrl, QTimer from PyQt5.QtCore import QTimer
import qutebrowser.commands.utils as cmdutils import qutebrowser.commands.utils as cmdutils
import qutebrowser.utils.config as config import qutebrowser.utils.config as config

View File

@ -1,75 +1,76 @@
"""Handler functions for different about:... pages.""" """Handler functions for different about:... pages."""
# Copyright 2014 Florian Bruhin (The Compiler) <mail@qutebrowser.org> # Copyright 2014 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
# #
# This file is part of qutebrowser. # This file is part of qutebrowser.
# #
# qutebrowser is free software: you can redistribute it and/or modify # qutebrowser is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or # the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version. # (at your option) any later version.
# #
# qutebrowser is distributed in the hope that it will be useful, # qutebrowser is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>. # along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
import qutebrowser.utils as utils import qutebrowser.utils as utils
_html_template = """ _html_template = """
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>{title}</title> <title>{title}</title>
</head> </head>
<body> <body>
{body} {body}
</body> </body>
</html> </html>
""" """
pyeval_output = None pyeval_output = None
def handle(url): def handle(url):
"""Handle about page with an url. """Handle about page with an url.
Returns HTML content. Returns HTML content.
""" """
if not utils.is_about_url(url): if not utils.is_about_url(url):
raise ValueError raise ValueError
handler = getattr(AboutHandlers, _transform_url(url)) handler = getattr(AboutHandlers, _transform_url(url))
return handler() return handler()
def _transform_url(url): def _transform_url(url):
return url.replace('http://', '').replace('about:', 'about_') """Transform a special URL to an AboutHandlers method name."""
return url.replace('http://', '').replace('about:', 'about_')
def _get_html(title, snippet):
"""Add HTML boilerplate to a html snippet. def _get_html(title, snippet):
"""Add HTML boilerplate to a html snippet.
title -- The title the page should have.
snippet -- The html snippet. title -- The title the page should have.
""" snippet -- The html snippet.
return _html_template.format(title=title, body=snippet).encode('UTF-8') """
return _html_template.format(title=title, body=snippet).encode('UTF-8')
class AboutHandlers:
"""Handlers for about:... pages.""" class AboutHandlers:
"""Handlers for about:... pages."""
@classmethod
def about_pyeval(cls): @classmethod
"""Handler for about:pyeval.""" def about_pyeval(cls):
return _get_html('pyeval', '<pre>{}</pre>'.format(pyeval_output)) """Handler for about:pyeval."""
return _get_html('pyeval', '<pre>{}</pre>'.format(pyeval_output))
@classmethod
def about_version(cls): @classmethod
"""Handler for about:version.""" def about_version(cls):
return _get_html('Version', '<pre>{}</pre>'.format(utils.version())) """Handler for about:version."""
return _get_html('Version', '<pre>{}</pre>'.format(utils.version()))

View File

@ -55,6 +55,7 @@ options = {
'too-many-arguments', 'too-many-arguments',
'too-many-locals', 'too-many-locals',
'global-statement', 'global-statement',
'no-init',
], ],
'flake8': [ 'flake8': [
'E241', # Multiple spaces after , 'E241', # Multiple spaces after ,