From 940b2d086090e98c0db119434e61f54a3a321753 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 7 Feb 2014 11:01:58 +0100 Subject: [PATCH] Fix checks --- qutebrowser/app.py | 2 +- qutebrowser/utils/about.py | 151 +++++++++++++++++++------------------ run_checks.py | 1 + 3 files changed, 78 insertions(+), 76 deletions(-) diff --git a/qutebrowser/app.py b/qutebrowser/app.py index 6a61fcacb..a5b1ebb39 100644 --- a/qutebrowser/app.py +++ b/qutebrowser/app.py @@ -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 diff --git a/qutebrowser/utils/about.py b/qutebrowser/utils/about.py index 33898a336..9eef71b1f 100644 --- a/qutebrowser/utils/about.py +++ b/qutebrowser/utils/about.py @@ -1,75 +1,76 @@ -"""Handler functions for different about:... pages.""" - -# Copyright 2014 Florian Bruhin (The Compiler) -# -# 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 . - -import qutebrowser.utils as utils - - -_html_template = """ - - - - - {title} - - -{body} - - -""" - - -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', '
{}
'.format(pyeval_output)) - - @classmethod - def about_version(cls): - """Handler for about:version.""" - return _get_html('Version', '
{}
'.format(utils.version())) +"""Handler functions for different about:... pages.""" + +# Copyright 2014 Florian Bruhin (The Compiler) +# +# 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 . + +import qutebrowser.utils as utils + + +_html_template = """ + + + + + {title} + + +{body} + + +""" + + +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', '
{}
'.format(pyeval_output)) + + @classmethod + def about_version(cls): + """Handler for about:version.""" + return _get_html('Version', '
{}
'.format(utils.version())) diff --git a/run_checks.py b/run_checks.py index f50045555..455f2f080 100644 --- a/run_checks.py +++ b/run_checks.py @@ -55,6 +55,7 @@ options = { 'too-many-arguments', 'too-many-locals', 'global-statement', + 'no-init', ], 'flake8': [ 'E241', # Multiple spaces after ,