From 966ceba1e6735a01c99206f8860ab183aebb2725 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 17 Feb 2014 12:23:52 +0100 Subject: [PATCH] Import cleanup --- qutebrowser/__init__.py | 32 ++++++++++++------------- qutebrowser/__main__.py | 4 +++- qutebrowser/app.py | 4 ++-- qutebrowser/commands/commands.py | 32 ++++++++++++------------- qutebrowser/commands/exceptions.py | 12 +++++----- qutebrowser/commands/keys.py | 10 ++++---- qutebrowser/commands/template.py | 6 ++--- qutebrowser/commands/utils.py | 10 ++++---- qutebrowser/models/commandcompletion.py | 4 ++-- qutebrowser/models/completion.py | 18 +++++++------- qutebrowser/models/completionfilter.py | 16 ++++++------- qutebrowser/simplebrowser.py | 4 +++- qutebrowser/utils/about.py | 4 ++-- qutebrowser/utils/config.py | 20 ++++++++-------- qutebrowser/utils/harfbuzz.py | 14 +++++------ qutebrowser/utils/misc.py | 4 ++-- qutebrowser/utils/signals.py | 4 ++-- qutebrowser/utils/style.py | 12 +++++----- qutebrowser/utils/url.py | 17 +++++++++++++ qutebrowser/widgets/browser.py | 20 ++++++++-------- qutebrowser/widgets/completion.py | 22 ++++++++--------- qutebrowser/widgets/crash.py | 4 ++-- qutebrowser/widgets/mainwindow.py | 6 ++--- qutebrowser/widgets/statusbar.py | 6 ++--- qutebrowser/widgets/tabbar.py | 6 ++--- 25 files changed, 156 insertions(+), 135 deletions(-) diff --git a/qutebrowser/__init__.py b/qutebrowser/__init__.py index 73c64cca7..ea42a673c 100644 --- a/qutebrowser/__init__.py +++ b/qutebrowser/__init__.py @@ -1,19 +1,3 @@ -"""A vim like browser based on Qt. - -Files: - __init__.py - This file. - __main__.py - Entry point for qutebrowser, to use - 'python -m qutebrowser'. - app.py - Main qutebrowser application> - simplebrowser.py - Simple browser for testing purposes. - -Subpackages: - commands - Handling of commands and key parsing. - utils - Misc utility code. - widgets - Qt widgets displayed on the screen. - -""" - # Copyright 2014 Florian Bruhin (The Compiler) # # This file is part of qutebrowser. @@ -31,6 +15,22 @@ Subpackages: # You should have received a copy of the GNU General Public License # along with qutebrowser. If not, see . +"""A vim like browser based on Qt. + +Files: + __init__.py - This file. + __main__.py - Entry point for qutebrowser, to use + 'python -m qutebrowser'. + app.py - Main qutebrowser application> + simplebrowser.py - Simple browser for testing purposes. + +Subpackages: + commands - Handling of commands and key parsing. + utils - Misc utility code. + widgets - Qt widgets displayed on the screen. + +""" + import os.path __version_info__ = (0, 0, 0) diff --git a/qutebrowser/__main__.py b/qutebrowser/__main__.py index e56098d63..91e7f1739 100644 --- a/qutebrowser/__main__.py +++ b/qutebrowser/__main__.py @@ -1,4 +1,4 @@ -"""Entry point for qutebrowser. Simply execute qutebrowser.""" +#!/usr/bin/python # Copyright 2014 Florian Bruhin (The Compiler) # @@ -17,6 +17,8 @@ # You should have received a copy of the GNU General Public License # along with qutebrowser. If not, see . +"""Entry point for qutebrowser. Simply execute qutebrowser.""" + from qutebrowser.app import QuteBrowser import sys diff --git a/qutebrowser/app.py b/qutebrowser/app.py index d110ff369..44f4be440 100644 --- a/qutebrowser/app.py +++ b/qutebrowser/app.py @@ -1,5 +1,3 @@ -"""Initialization of qutebrowser and application-wide things.""" - # Copyright 2014 Florian Bruhin (The Compiler) # # This file is part of qutebrowser. @@ -17,6 +15,8 @@ # You should have received a copy of the GNU General Public License # along with qutebrowser. If not, see . +"""Initialization of qutebrowser and application-wide things.""" + import os import sys import logging diff --git a/qutebrowser/commands/commands.py b/qutebrowser/commands/commands.py index 32bfc3bfa..116ce997e 100644 --- a/qutebrowser/commands/commands.py +++ b/qutebrowser/commands/commands.py @@ -1,19 +1,3 @@ -"""All command classes. - -These are automatically propagated from commands.utils -via inspect. - -A command class can set the following properties: - - nargs -- Number of arguments. Either a number, '?' (0 or 1), '+' (1 or - more), or '*' (any). Default: 0 - name -- The name of the command, or a list of aliases. - split_args -- If arguments should be split or not. Default: True - count -- If the command supports a count. Default: False - hide -- If the command should be hidden in tab completion. Default: False - -""" - # Copyright 2014 Florian Bruhin (The Compiler) # # This file is part of qutebrowser. @@ -31,6 +15,22 @@ A command class can set the following properties: # You should have received a copy of the GNU General Public License # along with qutebrowser. If not, see . +"""All command classes. + +These are automatically propagated from commands.utils +via inspect. + +A command class can set the following properties: + + nargs -- Number of arguments. Either a number, '?' (0 or 1), '+' (1 or + more), or '*' (any). Default: 0 + name -- The name of the command, or a list of aliases. + split_args -- If arguments should be split or not. Default: True + count -- If the command supports a count. Default: False + hide -- If the command should be hidden in tab completion. Default: False + +""" + from qutebrowser.commands.template import Command diff --git a/qutebrowser/commands/exceptions.py b/qutebrowser/commands/exceptions.py index d2ec5b14d..8a2d37719 100644 --- a/qutebrowser/commands/exceptions.py +++ b/qutebrowser/commands/exceptions.py @@ -1,9 +1,3 @@ -"""Exception classes for commands.utils and commands.template. - -Defined here to avoid circular dependency hell. - -""" - # Copyright 2014 Florian Bruhin (The Compiler) # # This file is part of qutebrowser. @@ -21,6 +15,12 @@ Defined here to avoid circular dependency hell. # You should have received a copy of the GNU General Public License # along with qutebrowser. If not, see . +"""Exception classes for commands.utils and commands.template. + +Defined here to avoid circular dependency hell. + +""" + class NoSuchCommandError(ValueError): diff --git a/qutebrowser/commands/keys.py b/qutebrowser/commands/keys.py index 15f60a4c2..7ba79c3a5 100644 --- a/qutebrowser/commands/keys.py +++ b/qutebrowser/commands/keys.py @@ -1,5 +1,3 @@ -"""Parse keypresses/keychains in the main window.""" - # Copyright 2014 Florian Bruhin (The Compiler) # # This file is part of qutebrowser. @@ -17,10 +15,12 @@ # You should have received a copy of the GNU General Public License # along with qutebrowser. If not, see . -import logging -import re +"""Parse keypresses/keychains in the main window.""" -from PyQt5.QtCore import QObject, pyqtSignal, Qt +import re +import logging + +from PyQt5.QtCore import pyqtSignal, Qt, QObject from PyQt5.QtGui import QKeySequence from qutebrowser.commands.utils import (CommandParser, ArgumentCountError, diff --git a/qutebrowser/commands/template.py b/qutebrowser/commands/template.py index 4bb51ac37..b99c79a9c 100644 --- a/qutebrowser/commands/template.py +++ b/qutebrowser/commands/template.py @@ -1,5 +1,3 @@ -"""Contains the Command class, a skeleton for a command.""" - # Copyright 2014 Florian Bruhin (The Compiler) # # This file is part of qutebrowser. @@ -17,9 +15,11 @@ # You should have received a copy of the GNU General Public License # along with qutebrowser. If not, see . +"""Contains the Command class, a skeleton for a command.""" + import logging -from PyQt5.QtCore import QObject, pyqtSignal +from PyQt5.QtCore import pyqtSignal, QObject from qutebrowser.commands.exceptions import ArgumentCountError diff --git a/qutebrowser/commands/utils.py b/qutebrowser/commands/utils.py index aa22bc3b3..0aeb8a000 100644 --- a/qutebrowser/commands/utils.py +++ b/qutebrowser/commands/utils.py @@ -1,5 +1,3 @@ -"""Contains various command utils, and the CommandParser.""" - # Copyright 2014 Florian Bruhin (The Compiler) # # This file is part of qutebrowser. @@ -17,10 +15,12 @@ # You should have received a copy of the GNU General Public License # along with qutebrowser. If not, see . -import inspect -import shlex +"""Contains various command utils, and the CommandParser.""" -from PyQt5.QtCore import QObject, pyqtSlot, pyqtSignal +import shlex +import inspect + +from PyQt5.QtCore import pyqtSlot, pyqtSignal, QObject from PyQt5.QtWebKitWidgets import QWebPage import qutebrowser.commands.commands diff --git a/qutebrowser/models/commandcompletion.py b/qutebrowser/models/commandcompletion.py index 8d4c94a97..25bb6e819 100644 --- a/qutebrowser/models/commandcompletion.py +++ b/qutebrowser/models/commandcompletion.py @@ -1,5 +1,3 @@ -"""A CompletionModel filled with all commands and descriptions.""" - # Copyright 2014 Florian Bruhin (The Compiler) # # This file is part of qutebrowser. @@ -17,6 +15,8 @@ # You should have received a copy of the GNU General Public License # along with qutebrowser. If not, see . +"""A CompletionModel filled with all commands and descriptions.""" + from qutebrowser.commands.utils import cmd_dict from qutebrowser.models.completion import CompletionModel diff --git a/qutebrowser/models/completion.py b/qutebrowser/models/completion.py index 04dbf230f..1e4ed488b 100644 --- a/qutebrowser/models/completion.py +++ b/qutebrowser/models/completion.py @@ -1,11 +1,3 @@ -"""The base completion model for completion in the command line. - -Contains: - CompletionModel -- A simple tree model based on Python data. - CompletionItem -- One item in the CompletionModel. - -""" - # Copyright 2014 Florian Bruhin (The Compiler) # # This file is part of qutebrowser. @@ -23,9 +15,17 @@ Contains: # You should have received a copy of the GNU General Public License # along with qutebrowser. If not, see . +"""The base completion model for completion in the command line. + +Contains: + CompletionModel -- A simple tree model based on Python data. + CompletionItem -- One item in the CompletionModel. + +""" + from collections import OrderedDict -from PyQt5.QtCore import QAbstractItemModel, Qt, QModelIndex, QVariant +from PyQt5.QtCore import Qt, QVariant, QAbstractItemModel, QModelIndex class CompletionModel(QAbstractItemModel): diff --git a/qutebrowser/models/completionfilter.py b/qutebrowser/models/completionfilter.py index 0f94408cb..7e17e586e 100644 --- a/qutebrowser/models/completionfilter.py +++ b/qutebrowser/models/completionfilter.py @@ -1,10 +1,3 @@ -"""A filtering/sorting base model for completions. - -Contains: - CompletionFilterModel -- A QSortFilterProxyModel subclass for completions. - -""" - # Copyright 2014 Florian Bruhin (The Compiler) # # This file is part of qutebrowser. @@ -22,7 +15,14 @@ Contains: # You should have received a copy of the GNU General Public License # along with qutebrowser. If not, see . -from PyQt5.QtCore import QModelIndex, QSortFilterProxyModel +"""A filtering/sorting base model for completions. + +Contains: + CompletionFilterModel -- A QSortFilterProxyModel subclass for completions. + +""" + +from PyQt5.QtCore import QSortFilterProxyModel, QModelIndex class CompletionFilterModel(QSortFilterProxyModel): diff --git a/qutebrowser/simplebrowser.py b/qutebrowser/simplebrowser.py index 126c4650b..740cd96f0 100644 --- a/qutebrowser/simplebrowser.py +++ b/qutebrowser/simplebrowser.py @@ -1,4 +1,4 @@ -"""Very simple browser for testing purposes.""" +#!/usr/bin/python # Copyright 2014 Florian Bruhin (The Compiler) # @@ -17,6 +17,8 @@ # You should have received a copy of the GNU General Public License # along with qutebrowser. If not, see . +"""Very simple browser for testing purposes.""" + import sys from PyQt5.QtCore import QUrl diff --git a/qutebrowser/utils/about.py b/qutebrowser/utils/about.py index 17476bdd2..7b95e398a 100644 --- a/qutebrowser/utils/about.py +++ b/qutebrowser/utils/about.py @@ -1,5 +1,3 @@ -"""Handler functions for different about:... pages.""" - # Copyright 2014 Florian Bruhin (The Compiler) # # This file is part of qutebrowser. @@ -17,6 +15,8 @@ # You should have received a copy of the GNU General Public License # along with qutebrowser. If not, see . +"""Handler functions for different about:... pages.""" + from qutebrowser.utils.version import version from qutebrowser.utils.url import is_about_url diff --git a/qutebrowser/utils/config.py b/qutebrowser/utils/config.py index 1f63a6db6..5cecca41e 100644 --- a/qutebrowser/utils/config.py +++ b/qutebrowser/utils/config.py @@ -1,12 +1,3 @@ -"""Configuration storage and config-related utilities. - -config -- The main Config object. -colordict -- All configured colors. -default_config -- The default config as dict. -MONOSPACE -- A list of suitable monospace fonts. - -""" - # Copyright 2014 Florian Bruhin (The Compiler) # # This file is part of qutebrowser. @@ -24,9 +15,18 @@ MONOSPACE -- A list of suitable monospace fonts. # You should have received a copy of the GNU General Public License # along with qutebrowser. If not, see . -import os.path +"""Configuration storage and config-related utilities. + +config -- The main Config object. +colordict -- All configured colors. +default_config -- The default config as dict. +MONOSPACE -- A list of suitable monospace fonts. + +""" + import os import io +import os.path import logging from configparser import ConfigParser, ExtendedInterpolation diff --git a/qutebrowser/utils/harfbuzz.py b/qutebrowser/utils/harfbuzz.py index 76213d084..f0d348bed 100644 --- a/qutebrowser/utils/harfbuzz.py +++ b/qutebrowser/utils/harfbuzz.py @@ -1,10 +1,3 @@ -"""Fixer to set QT_HARFBUZZ variable. - -In its own file so it doesn't include any Qt stuff, because if it did, it -wouldn't work. - -""" - # Copyright 2014 Florian Bruhin (The Compiler) # # This file is part of qutebrowser. @@ -22,6 +15,13 @@ wouldn't work. # You should have received a copy of the GNU General Public License # along with qutebrowser. If not, see . +"""Fixer to set QT_HARFBUZZ variable. + +In its own file so it doesn't include any Qt stuff, because if it did, it +wouldn't work. + +""" + import os import sys diff --git a/qutebrowser/utils/misc.py b/qutebrowser/utils/misc.py index 86c1efc76..a7420bf35 100644 --- a/qutebrowser/utils/misc.py +++ b/qutebrowser/utils/misc.py @@ -1,5 +1,3 @@ -"""Other utilities which don't fit anywhere else.""" - # Copyright 2014 Florian Bruhin (The Compiler) # # This file is part of qutebrowser. @@ -17,6 +15,8 @@ # You should have received a copy of the GNU General Public License # along with qutebrowser. If not, see . +"""Other utilities which don't fit anywhere else.""" + import os.path from PyQt5.QtCore import pyqtRemoveInputHook diff --git a/qutebrowser/utils/signals.py b/qutebrowser/utils/signals.py index 36257ef0c..a124f3cae 100644 --- a/qutebrowser/utils/signals.py +++ b/qutebrowser/utils/signals.py @@ -1,5 +1,3 @@ -"""Utilities regarding signals.""" - # Copyright 2014 Florian Bruhin (The Compiler) # # This file is part of qutebrowser. @@ -17,6 +15,8 @@ # You should have received a copy of the GNU General Public License # along with qutebrowser. If not, see . +"""Utilities regarding signals.""" + import re import logging from collections import OrderedDict diff --git a/qutebrowser/utils/style.py b/qutebrowser/utils/style.py index 81f2eb6bd..344ab959c 100644 --- a/qutebrowser/utils/style.py +++ b/qutebrowser/utils/style.py @@ -1,9 +1,3 @@ -"""Qt style to remove Ubuntu focus rectangle uglyness. - -We might also use this to do more in the future. - -""" - # Copyright 2014 Florian Bruhin (The Compiler) # # This file is part of qutebrowser. @@ -21,6 +15,12 @@ We might also use this to do more in the future. # You should have received a copy of the GNU General Public License # along with qutebrowser. If not, see . +"""Qt style to remove Ubuntu focus rectangle uglyness. + +We might also use this to do more in the future. + +""" + import functools from PyQt5.QtWidgets import QCommonStyle, QStyle diff --git a/qutebrowser/utils/url.py b/qutebrowser/utils/url.py index 3af72e468..b48a97ece 100644 --- a/qutebrowser/utils/url.py +++ b/qutebrowser/utils/url.py @@ -1,3 +1,20 @@ +# 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 . + """Utils regarding URL handling.""" import re diff --git a/qutebrowser/widgets/browser.py b/qutebrowser/widgets/browser.py index ab98bb08a..6cea0d5c8 100644 --- a/qutebrowser/widgets/browser.py +++ b/qutebrowser/widgets/browser.py @@ -1,10 +1,3 @@ -"""The main browser widget. - -Defines BrowserTab (our own QWebView subclass) and TabbedBrowser (a TabWidget -containing BrowserTabs). - -""" - # Copyright 2014 Florian Bruhin (The Compiler) # # This file is part of qutebrowser. @@ -22,22 +15,29 @@ containing BrowserTabs). # You should have received a copy of the GNU General Public License # along with qutebrowser. If not, see . +"""The main browser widget. + +Defines BrowserTab (our own QWebView subclass) and TabbedBrowser (a TabWidget +containing BrowserTabs). + +""" + import logging import functools import sip -from PyQt5.QtWidgets import QShortcut, QApplication, QSizePolicy +from PyQt5.QtWidgets import QApplication, QShortcut, QSizePolicy from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt, QEvent from PyQt5.QtGui import QClipboard from PyQt5.QtPrintSupport import QPrintPreviewDialog -from PyQt5.QtNetwork import QNetworkReply, QNetworkAccessManager +from PyQt5.QtNetwork import QNetworkAccessManager, QNetworkReply from PyQt5.QtWebKit import QWebSettings from PyQt5.QtWebKitWidgets import QWebView, QWebPage import qutebrowser.utils.about as about import qutebrowser.utils.url as urlutils from qutebrowser.widgets.tabbar import TabWidget -from qutebrowser.utils.signals import dbg_signal, SignalCache +from qutebrowser.utils.signals import SignalCache, dbg_signal from qutebrowser.utils.misc import read_file diff --git a/qutebrowser/widgets/completion.py b/qutebrowser/widgets/completion.py index 09b7a947f..7975f325a 100644 --- a/qutebrowser/widgets/completion.py +++ b/qutebrowser/widgets/completion.py @@ -1,10 +1,3 @@ -"""Completion view for statusbar command section. - -Defines a CompletionView which uses CompletionFiterModel and CompletionModel -subclasses to provide completions. - -""" - # Copyright 2014 Florian Bruhin (The Compiler) # # This file is part of qutebrowser. @@ -22,12 +15,19 @@ subclasses to provide completions. # You should have received a copy of the GNU General Public License # along with qutebrowser. If not, see . +"""Completion view for statusbar command section. + +Defines a CompletionView which uses CompletionFiterModel and CompletionModel +subclasses to provide completions. + +""" + import html -from PyQt5.QtWidgets import (QTreeView, QStyledItemDelegate, QStyle, - QStyleOptionViewItem, QSizePolicy) -from PyQt5.QtCore import (pyqtSlot, pyqtSignal, QRectF, QRect, QPoint, Qt, - QItemSelectionModel, QSize) +from PyQt5.QtWidgets import (QStyle, QStyleOptionViewItem, QTreeView, + QStyledItemDelegate, QSizePolicy) +from PyQt5.QtCore import (pyqtSlot, pyqtSignal, Qt, QRect, QRectF, QPoint, + QSize, QItemSelectionModel) from PyQt5.QtGui import (QIcon, QPalette, QTextDocument, QTextOption, QTextCursor) diff --git a/qutebrowser/widgets/crash.py b/qutebrowser/widgets/crash.py index 1603be812..450505d0c 100644 --- a/qutebrowser/widgets/crash.py +++ b/qutebrowser/widgets/crash.py @@ -20,8 +20,8 @@ import sys import traceback -from PyQt5.QtWidgets import (QDialog, QLabel, QTextEdit, QVBoxLayout, - QHBoxLayout, QPushButton) +from PyQt5.QtWidgets import (QDialog, QLabel, QTextEdit, QPushButton, + QVBoxLayout, QHBoxLayout) import qutebrowser.utils.config as config from qutebrowser.utils.version import version diff --git a/qutebrowser/widgets/mainwindow.py b/qutebrowser/widgets/mainwindow.py index df88aa3a2..5674775ab 100644 --- a/qutebrowser/widgets/mainwindow.py +++ b/qutebrowser/widgets/mainwindow.py @@ -1,5 +1,3 @@ -"""The main window of QuteBrowser.""" - # Copyright 2014 Florian Bruhin (The Compiler) # # This file is part of qutebrowser. @@ -17,7 +15,9 @@ # You should have received a copy of the GNU General Public License # along with qutebrowser. If not, see . -from PyQt5.QtWidgets import QVBoxLayout, QWidget +"""The main window of QuteBrowser.""" + +from PyQt5.QtWidgets import QWidget, QVBoxLayout from qutebrowser.widgets.statusbar import StatusBar from qutebrowser.widgets.browser import TabbedBrowser diff --git a/qutebrowser/widgets/statusbar.py b/qutebrowser/widgets/statusbar.py index cc65979fe..0c245fc43 100644 --- a/qutebrowser/widgets/statusbar.py +++ b/qutebrowser/widgets/statusbar.py @@ -20,10 +20,10 @@ import logging from PyQt5.QtCore import pyqtSignal, pyqtSlot, pyqtProperty, Qt -from PyQt5.QtWidgets import (QLineEdit, QShortcut, QHBoxLayout, QWidget, - QSizePolicy, QProgressBar, QLabel, QStyle, +from PyQt5.QtWidgets import (QWidget, QLineEdit, QProgressBar, QLabel, + QHBoxLayout, QSizePolicy, QShortcut, QStyle, QStyleOption) -from PyQt5.QtGui import QValidator, QKeySequence, QPainter +from PyQt5.QtGui import QPainter, QKeySequence, QValidator import qutebrowser.utils.config as config import qutebrowser.commands.keys as keys diff --git a/qutebrowser/widgets/tabbar.py b/qutebrowser/widgets/tabbar.py index 965e735ab..9a5c75a62 100644 --- a/qutebrowser/widgets/tabbar.py +++ b/qutebrowser/widgets/tabbar.py @@ -1,5 +1,3 @@ -"""The tab widget used for TabbedBrowser from browser.py.""" - # Copyright 2014 Florian Bruhin (The Compiler) # # This file is part of qutebrowser. @@ -17,8 +15,10 @@ # You should have received a copy of the GNU General Public License # along with qutebrowser. If not, see . -from PyQt5.QtWidgets import QTabWidget, QTabBar, QSizePolicy +"""The tab widget used for TabbedBrowser from browser.py.""" + from PyQt5.QtCore import Qt +from PyQt5.QtWidgets import QTabWidget, QTabBar, QSizePolicy import qutebrowser.utils.config as config from qutebrowser.utils.style import Style