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()
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.utils.config as config

View File

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