Remove blank lines before """ in docstrings.

pep257 has changed in this regard so we reflect this change.
This commit is contained in:
Florian Bruhin 2014-04-10 14:21:27 +02:00
parent cba2d4d450
commit c5ca0e56be
33 changed files with 1 additions and 227 deletions

View File

@ -78,7 +78,6 @@ class QuteBrowser(QApplication):
_timers: List of used QTimers so they don't get GCed.
_shutting_down: True if we're currently shutting down.
_quit_status: The current quitting status.
"""
def __init__(self):
@ -142,7 +141,6 @@ class QuteBrowser(QApplication):
Return:
Argument namespace from argparse.
"""
parser = ArgumentParser("usage: %(prog)s [options]")
parser.add_argument('-l', '--log', dest='loglevel',
@ -181,7 +179,6 @@ class QuteBrowser(QApplication):
"""Initialisation of the qutebrowser commands.
Registers all commands, connects its signals, and sets up keyparser.
"""
for key, cmd in sorted(cmdutils.cmd_dict.items()):
cmd.signal.connect(self.command_handler)
@ -197,7 +194,6 @@ class QuteBrowser(QApplication):
"""Process initial positional args.
URLs to open have no prefix, commands to execute begin with a colon.
"""
# QNetworkAccessManager::createRequest will hang for over a second, so
# we make sure the GUI is refreshed here, so the start seems faster.
@ -223,7 +219,6 @@ class QuteBrowser(QApplication):
This sets up the uncaught exception hook, quits with an appropriate
exit status, and handles Ctrl+C properly by passing control to the
Python interpreter once all 500ms.
"""
signal(SIGINT, lambda *args: self.exit(128 + SIGINT))
timer = QTimer()
@ -238,7 +233,6 @@ class QuteBrowser(QApplication):
Return:
A list of open pages, or an empty list.
"""
pages = []
if self.mainwindow is None:
@ -268,7 +262,6 @@ class QuteBrowser(QApplication):
It'll try very hard to write all open tabs to a file, and then exit
gracefully.
"""
# pylint: disable=broad-except
@ -324,7 +317,6 @@ class QuteBrowser(QApplication):
Args:
The sender of the quit signal (string)
"""
self._quit_status[sender] = True
logging.debug("maybe_quit called from {}, quit status {}".format(
@ -341,7 +333,6 @@ class QuteBrowser(QApplication):
Args:
s: The string to evaluate.
"""
try:
r = eval(s)
@ -359,7 +350,6 @@ class QuteBrowser(QApplication):
Raises:
Always raises Exception.
"""
raise Exception("Forced crash")
@ -373,7 +363,6 @@ class QuteBrowser(QApplication):
Args:
do_quit: Whether to quit after shutting down.
"""
if self._shutting_down:
return
@ -406,7 +395,6 @@ class QuteBrowser(QApplication):
"""Quit application after a shutdown.
Gets called when all tabs finished shutting down after shutdown().
"""
logging.debug("Shutdown complete, quitting.")
self.quit()
@ -423,7 +411,6 @@ class QuteBrowser(QApplication):
func: The function name to be called (as string).
count: The count given to the command, or None.
args: A list of arguments given to the command.
"""
(instance, func, count, args) = tpl
if instance == '':

View File

@ -43,7 +43,6 @@ class Command(QObject):
Signals:
signal: Gets emitted when something should be called via handle_command
from the app.py context.
"""
# FIXME:
@ -75,7 +74,6 @@ class Command(QObject):
Raise:
ArgumentCountError if the argument count is wrong.
"""
if self.nargs[1] is None and self.nargs[0] <= len(args):
pass
@ -101,7 +99,6 @@ class Command(QObject):
Emit:
signal: When the command has an instance and should be handled from
the app.py context.
"""
dbgout = ["command called:", self.name]
if args:

View File

@ -18,7 +18,6 @@
"""Exception classes for commands modules.
Defined here to avoid circular dependency hell.
"""

View File

@ -45,7 +45,6 @@ class KeyParser(QObject):
arg: Text to set.
keystring_updated: Emitted when the keystring is updated.
arg: New keystring.
"""
set_cmd_text = pyqtSignal(str)
@ -72,7 +71,6 @@ class KeyParser(QObject):
Return:
True if event has been handled, False otherwise.
"""
MODMASK2STR = {
Qt.ControlModifier: 'Ctrl',
@ -112,7 +110,6 @@ class KeyParser(QObject):
Emit:
set_cmd_text: If the keystring should be shown in the statusbar.
"""
# FIXME maybe we can do this in an easier way by using QKeySeqyence
# which has a matches method.
@ -170,7 +167,6 @@ class KeyParser(QObject):
A tuple (matchtype, hay) where matchtype is MATCH_DEFINITIVE,
MATCH_PARTIAL or MATCH_NONE and hay is the long keystring where the
part was found in.
"""
try:
cmdstr_hay = self._bindings[cmdstr_needle]
@ -196,7 +192,6 @@ class KeyParser(QObject):
Return:
The normalized keystring.
"""
replacements = [
('Control', 'Ctrl'),
@ -222,7 +217,6 @@ class KeyParser(QObject):
Emit:
set_cmd_text: If a partial command should be printed to the
statusbar.
"""
try:
self.commandparser.run(cmdstr, count=count, ignore_exc=ignore_exc)
@ -242,7 +236,6 @@ class KeyParser(QObject):
Args:
sect: The section to get the keybindings from.
"""
for (key, cmd) in sect.items():
if key.startswith('@') and key.endswith('@'):
@ -263,7 +256,6 @@ class KeyParser(QObject):
Emit:
keystring_updated: If a new keystring should be set.
"""
handled = self._handle_modifier_key(e)
if not handled:

View File

@ -41,7 +41,6 @@ class SearchParser(QObject):
do_search: Emitted when a search should be started.
arg 1: Search string.
arg 2: Flags to use.
"""
do_search = pyqtSignal(str, 'QWebPage::FindFlags')
@ -60,7 +59,6 @@ class SearchParser(QObject):
Emit:
do_search: If a search should be started.
"""
if self._text is not None and self._text != text:
self.do_search.emit('', 0)
@ -80,7 +78,6 @@ class SearchParser(QObject):
Args:
text: The text to search for.
"""
self._search(text)
@ -90,7 +87,6 @@ class SearchParser(QObject):
Args:
text: The text to search for.
"""
self._search(text, rev=True)
@ -102,7 +98,6 @@ class SearchParser(QObject):
Emit:
do_search: If a search should be started.
"""
if self._text is not None:
for i in range(count): # pylint: disable=unused-variable
@ -116,7 +111,6 @@ class CommandParser:
Attributes:
_cmd: The command which was parsed.
_args: The arguments which were parsed.
"""
def __init__(self):
@ -135,7 +129,6 @@ class CommandParser:
Return:
A split string commandline, e.g ['open', 'www.google.com']
"""
parts = text.strip().split(maxsplit=1)
if not parts:
@ -172,7 +165,6 @@ class CommandParser:
Args:
count: Count to pass to the command.
"""
if count is not None:
self._cmd.run(self._args, count=count)
@ -198,7 +190,6 @@ class CommandParser:
Return:
True if command was called (handler returnstatus is ignored!).
False if command wasn't called (there was an ignored exception).
"""
if ';;' in text:
retvals = []
@ -233,7 +224,6 @@ def split_cmdline(text):
Return:
A list of strings.
"""
parser = CommandParser()
try:

View File

@ -41,7 +41,6 @@ class register:
hide: Whether to hide the command or not.
completion: Which completion to use for arguments, as a list of
strings.
"""
def __init__(self, instance=None, name=None, nargs=None, split_args=True,
@ -52,7 +51,6 @@ class register:
Arguments:
See class attributes.
"""
self.name = name
self.split_args = split_args
@ -74,7 +72,6 @@ class register:
Return:
The original function (unmodified).
"""
# FIXME: only register commands once
names = []
@ -111,7 +108,6 @@ class register:
N (N, N)
+ (1, None)
* (0, None)
"""
# pylint: disable=no-member
# pylint: disable=unpacking-non-sequence

View File

@ -20,7 +20,6 @@
This borrows a lot of ideas from configparser, but also has some things that
are fundamentally different. This is why nothing inherts from configparser, but
we borrow some methods and classes from there where it makes sense.
"""
import os
@ -63,7 +62,6 @@ def init(configdir):
Args:
configdir: The directory where the configs are stored in.
"""
global config, state
logging.debug("Config init, configdir {}".format(configdir))
@ -85,7 +83,6 @@ class Config:
_configfile: The config file path.
_interpolation: An configparser.Interpolation object
_proxies: configparser.SectionProxy objects for sections.
"""
def __init__(self, configdir, fname):
@ -186,7 +183,6 @@ class Config:
Return:
True if the option and section exist, False otherwise.
"""
if section not in self.config:
return False
@ -201,7 +197,6 @@ class Config:
Return:
True if the option existed, False otherwise.
"""
try:
sectdict = self.config[section]
@ -226,7 +221,6 @@ class Config:
Return:
The value of the option.
"""
val = self.get(section, option)
message.info("{} {} = {}".format(section, option, val))
@ -239,7 +233,6 @@ class Config:
option: The option name
fallback: A fallback value.
raw: Whether to get the uninterpolated, untransformed value.
"""
logging.debug("getting {} -> {}".format(section, option))
try:
@ -274,7 +267,6 @@ class Config:
Arguments:
*args: Get passed to self.set().
"""
# FIXME completion for values
try:
@ -309,7 +301,6 @@ class Config:
Return:
The changed config part as string.
"""
lines = []
for secname, section in self.config.items():
@ -336,7 +327,6 @@ class ReadConfigParser(ConfigParser):
Attributes:
_configdir: The directory to read the config from.
_configfile: The config file path.
"""
def __init__(self, configdir, fname):
@ -345,7 +335,6 @@ class ReadConfigParser(ConfigParser):
Args:
configdir: Directory to read the config from.
fname: Filename of the config file.
"""
super().__init__(interpolation=None)
self.optionxform = lambda opt: opt # be case-insensitive
@ -377,7 +366,6 @@ class SectionProxy(MutableMapping):
Attributes:
_conf: The Config object.
_name: The section name.
"""
# pylint: disable=redefined-builtin
@ -388,7 +376,6 @@ class SectionProxy(MutableMapping):
Arguments:
conf: The Config object.
name: The section name.
"""
self._conf = conf
self._name = name
@ -429,7 +416,6 @@ class SectionProxy(MutableMapping):
option: The option name to get.
fallback: A fallback value.
raw: Whether to get a raw value or not.
"""
return self._conf.get(self._name, option, raw=raw, fallback=fallback)

View File

@ -34,7 +34,6 @@ class ValidValues:
values: A list with the allowed untransformed values.
descriptions: A dict with value/desc mappings.
show: Whether to show the values in the config or not.
"""
def __init__(self, *vals, show=True):
@ -68,7 +67,6 @@ class SettingValue:
default: Default value if the user has not overridden it, as a string.
value: (property) The currently valid, most important value.
rawvalue: The current value as a raw string.
"""
def __init__(self, typ, default=None):
@ -77,7 +75,6 @@ class SettingValue:
Args:
typ: The BaseType to use.
default: Raw value to set.
"""
self.typ = typ()
self.rawvalue = None
@ -112,7 +109,6 @@ class BaseType:
valid_values: Possible values if they can be expressed as a fixed
string. ValidValues instance.
typestr: The name of the type to appear in the config.
"""
typestr = None
@ -130,7 +126,6 @@ class BaseType:
Return:
The transformed value.
"""
return value
@ -147,7 +142,6 @@ class BaseType:
ValidationError if the value was invalid.
NotImplementedError if self.valid_values is not defined and this
method should be overridden.
"""
if self.valid_values is not None:
if value not in self.valid_values:

View File

@ -35,7 +35,6 @@ class KeyValue:
key: string
value: SettingValue
descriptions: A dict with the description strings for the keys.
"""
def __init__(self, *args):
@ -45,7 +44,6 @@ class KeyValue:
*args: Key/Value pairs to set.
key: string
value: SettingValue
"""
if args:
self.descriptions = {}
@ -62,7 +60,6 @@ class KeyValue:
Return:
The value, as value class.
"""
return self.values[key]
@ -72,7 +69,6 @@ class KeyValue:
Args:
key: The key to set the value for, as a string.
value: The value to set, as a string
"""
self.values[key].value = value
@ -119,7 +115,6 @@ class ValueList:
#descriptions: A dict with the description strings for the keys.
# Currently a global empty dict to be compatible with
# KeyValue section.
"""
def __init__(self, keytype, valtype, *defaults):
@ -147,7 +142,6 @@ class ValueList:
Return:
The value, as value class.
"""
try:
return self.values[key]
@ -160,7 +154,6 @@ class ValueList:
Args:
key: The key to set the value for, as a string.
value: The value to set, as a string
"""
self.values[key] = conftypes.SettingValue(self.valtype)
self.values[key].value = value

View File

@ -31,7 +31,6 @@ def get_stylesheet(template):
Return:
The formatted template as string.
"""
global _colordict, _fontdict
if _colordict is None:
@ -63,7 +62,6 @@ class ColorDict(dict):
If the key has a .bg. element in it, return background-color: X;.
In all other cases, return the plain value.
"""
try:
val = super().__getitem__(key)
@ -84,7 +82,6 @@ class ColorDict(dict):
Return:
A value, or None if the value wasn't found.
"""
try:
return super().__getitem__(key)
@ -107,7 +104,6 @@ class FontDict(dict):
(Color not defined, so no output in the stylesheet)
In all other cases, return font: <value>.
"""
try:
val = super().__getitem__(key)
@ -124,7 +120,6 @@ class FontDict(dict):
Return:
A value, or None if the value wasn't found.
"""
try:
return super().__getitem__(key)

View File

@ -33,7 +33,6 @@ class CompletionModel(QAbstractItemModel):
_id_map: A mapping from Python object IDs (from id()) to objects, to be
used as internalIndex for the model.
_root: The root item.
"""
def __init__(self, parent=None):
@ -51,7 +50,6 @@ class CompletionModel(QAbstractItemModel):
Return:
The CompletionItem for index, or the root CompletionItem if the
index was invalid.
"""
if index.isValid():
return self._id_map[index.internalId()]
@ -67,7 +65,6 @@ class CompletionModel(QAbstractItemModel):
Return:
A list of (startidx, endidx) tuples.
"""
pos1 = pos2 = 0
marks = []
@ -86,7 +83,6 @@ class CompletionModel(QAbstractItemModel):
Args:
needle: The string to mark.
"""
for i in range(self.rowCount()):
cat = self.index(i, 0)
@ -104,7 +100,6 @@ class CompletionModel(QAbstractItemModel):
Return:
The created CompletionItem.
"""
cat = CompletionItem([name], self._root)
self._id_map[id(cat)] = cat
@ -121,7 +116,6 @@ class CompletionModel(QAbstractItemModel):
Return:
The created CompletionItem.
"""
item = CompletionItem((name, desc), parent=cat)
self._id_map[id(item)] = item
@ -137,7 +131,6 @@ class CompletionModel(QAbstractItemModel):
position: The start row to remove.
count: How many rows to remove.
parent: The parent QModelIndex.
"""
node = self._node(parent)
self.beginRemoveRows(parent, position, position + count - 1)
@ -155,7 +148,6 @@ class CompletionModel(QAbstractItemModel):
Return:
Column count as an integer.
"""
# pylint: disable=unused-argument
return self._root.column_count()
@ -171,7 +163,6 @@ class CompletionModel(QAbstractItemModel):
Return:
Row count as an integer.
"""
if parent.column() > 0:
return 0
@ -193,7 +184,6 @@ class CompletionModel(QAbstractItemModel):
Return:
The data as QVariant or an invalid QVariant on error.
"""
if not index.isValid():
return QVariant()
@ -217,7 +207,6 @@ class CompletionModel(QAbstractItemModel):
Return:
The data as QVariant or an invalid QVariant on error.
"""
if orientation == Qt.Horizontal and role == Qt.DisplayRole:
return QVariant(self._root.data(section))
@ -238,7 +227,6 @@ class CompletionModel(QAbstractItemModel):
Emit:
dataChanged when the data was changed.
"""
if not index.isValid():
return False
@ -262,7 +250,6 @@ class CompletionModel(QAbstractItemModel):
Return:
The item flags, or Qt.NoItemFlags on error.
"""
# FIXME categories are not selectable, but moving via arrow keys still
# tries to select them
@ -286,7 +273,6 @@ class CompletionModel(QAbstractItemModel):
Return:
A generated QModelIndex or an invalid QModelIndex on failure.
"""
if parent.model() is not None and parent.model() is not self:
logging.warn("index() called with wrong parent! - "
@ -322,7 +308,6 @@ class CompletionModel(QAbstractItemModel):
Return:
The parent's QModelIndex or an invalid QModelIndex on failure.
"""
if not index.isValid():
return QModelIndex()
@ -338,7 +323,6 @@ class CompletionModel(QAbstractItemModel):
Raise:
NotImplementedError, should be overwritten in a superclass.
"""
raise NotImplementedError
@ -352,7 +336,6 @@ class CompletionItem():
children: The children of this item.
_data: The data of this item.
_marks: The marks of this item.
"""
def __init__(self, data, parent=None):
@ -361,7 +344,6 @@ class CompletionItem():
Args:
data: The data for the model, as tuple (columns).
parent: An optional parent item.
"""
self.parent = parent
self.children = []
@ -380,7 +362,6 @@ class CompletionItem():
Raise:
ValueError if the role is invalid.
"""
if role == Qt.DisplayRole:
return self._data[column]
@ -399,7 +380,6 @@ class CompletionItem():
Raise:
ValueError if the role is invalid.
"""
if role == Qt.DisplayRole:
self._data[column] = value
@ -413,7 +393,6 @@ class CompletionItem():
Return:
The column count.
"""
return len(self._data)
@ -422,7 +401,6 @@ class CompletionItem():
Return:
The row index of the item, or 0 if we're a root item.
"""
if self.parent:
return self.parent.children.index(self)

View File

@ -19,7 +19,6 @@
Contains:
CompletionFilterModel -- A QSortFilterProxyModel subclass for completions.
"""
import logging
@ -34,7 +33,6 @@ class CompletionFilterModel(QSortFilterProxyModel):
Attributes:
srcmodel: The source model of this QSFPM.
_pattern: The pattern to filter with, used in pattern property.
"""
def __init__(self, source, parent=None):
@ -59,7 +57,6 @@ class CompletionFilterModel(QSortFilterProxyModel):
Args:
val: The value to set.
"""
self._pattern = val
self.invalidateFilter()
@ -105,7 +102,6 @@ class CompletionFilterModel(QSortFilterProxyModel):
Return:
True if self.pattern is contained in item, or if it's a root item
(category). False in all other cases
"""
if parent == QModelIndex():
return True
@ -128,7 +124,6 @@ class CompletionFilterModel(QSortFilterProxyModel):
Return:
True if left < right, else False
"""
left = self.srcmodel.data(lindex).value()
right = self.srcmodel.data(rindex).value()

View File

@ -32,7 +32,6 @@ class NetworkManager(QNetworkAccessManager):
_requests: Pending requests.
_scheme_handlers: A dictionary (scheme -> handler) of supported custom
schemes.
"""
def __init__(self, parent=None):
@ -60,7 +59,6 @@ class NetworkManager(QNetworkAccessManager):
Return:
A QNetworkReply.
"""
scheme = req.url().scheme()
logging.debug("new req, scheme {}, handlers {}".format(

View File

@ -51,7 +51,6 @@ def _get_html(title, snippet):
Return:
HTML content as bytes.
"""
return _HTML_TEMPLATE.format(title=title, body=snippet).encode('UTF-8')
@ -68,7 +67,6 @@ class QuteSchemeHandler(SchemeHandler):
Return:
The method name qute_*
"""
return url.replace('http://', '').replace('qute:', 'qute_')
@ -82,7 +80,6 @@ class QuteSchemeHandler(SchemeHandler):
Return:
A QNetworkReply.
"""
# FIXME handle unknown pages
# FIXME adjust URLutils based on handlers

View File

@ -42,7 +42,6 @@ class SchemeHandler(QObject):
Raise:
NotImplementedError because this needs to be overwritten by
subclasses.
"""
raise NotImplementedError
@ -62,7 +61,6 @@ class SpecialNetworkReply(QNetworkReply):
Emit:
metaDataChanged and readyRead and finished after initializing.
"""
super().__init__(parent)
@ -92,7 +90,6 @@ class SpecialNetworkReply(QNetworkReply):
Return:
bytes available (int)
"""
return len(self._data) + super().bytesAvailable()
@ -104,7 +101,6 @@ class SpecialNetworkReply(QNetworkReply):
Return:
bytestring containing the data
"""
len_ = min(maxlen, len(self._data))
buf = bytes(self._data[:len_])

View File

@ -35,7 +35,6 @@ def set_trace():
"""Set a tracepoint in the Python debugger that works with Qt.
Based on http://stackoverflow.com/a/1745965/2085149
"""
print()
print("When done debugging, remember to execute:")
@ -50,7 +49,6 @@ def trace_lines(do_trace):
Args:
do_trace: Whether to start tracing (True) or stop it (False).
"""
def trace(frame, event, _):
"""Trace function passed to sys.settrace."""

View File

@ -19,7 +19,6 @@
In its own file so it doesn't include any Qt stuff, because if it did, it
wouldn't work.
"""
import os
@ -34,7 +33,6 @@ def fix():
This fixes crashes on various sites.
See https://bugreports.qt-project.org/browse/QTBUG-36099
"""
if sys.platform.startswith('linux'):
# Switch to old but stable font rendering engine

View File

@ -36,7 +36,6 @@ def init():
This needs to be done by hand because the import time is before Qt is ready
for everything.
"""
global bridge
bridge = MessageBridge()

View File

@ -31,7 +31,6 @@ def read_file(filename):
Return:
The file contents as string.
"""
fn = os.path.join(qutebrowser.basedir, filename)
with open(fn, 'r', encoding='UTF-8') as f:
@ -47,6 +46,5 @@ def dotted_getattr(obj, path):
Return:
The object at path.
"""
return reduce(getattr, path.split('.'), obj)

View File

@ -32,7 +32,6 @@ def signal_name(sig):
Return:
The cleaned up signal name.
"""
m = re.match(r'[0-9]+(.*)\(.*\)', sig.signal)
return m.group(1)
@ -47,7 +46,6 @@ def dbg_signal(sig, args):
Return:
A human-readable string representation of signal/args.
"""
return '{}({})'.format(signal_name(sig), ', '.join(map(str, args)))
@ -59,7 +57,6 @@ class SignalCache(QObject):
Attributes:
_uncached: A list of signals which should not be cached.
_signal_dict: The internal mapping of signals we got.
"""
def __init__(self, uncached=None):
@ -68,7 +65,6 @@ class SignalCache(QObject):
Args:
uncached: A list of signal names (as string) which should never be
cached.
"""
super().__init__()
if uncached is None:
@ -94,7 +90,6 @@ class SignalCache(QObject):
Emit:
Cached signals.
"""
if not self._signal_needs_caching(sig):
return

View File

@ -18,7 +18,6 @@
"""Qt style to remove Ubuntu focus rectangle uglyness.
We might also use this to do more in the future.
"""
import functools
@ -40,7 +39,6 @@ class Style(QCommonStyle):
Attributes:
_style: The base/"parent" style.
"""
def __init__(self, style):
@ -50,7 +48,6 @@ class Style(QCommonStyle):
Args:
style: The base/"parent" style.
"""
self._style = style
for method in ['drawComplexControl', 'drawControl', 'drawItemPixmap',
@ -74,7 +71,6 @@ class Style(QCommonStyle):
option: const QStyleOption * opt
painter: QPainter * p
widget: const QWidget * widget
"""
if element == QStyle.PE_FrameFocusRect:
return

View File

@ -38,7 +38,6 @@ def _get_search_url(txt):
Raise:
ValueError if there is no template or no search term was found.
"""
logging.debug('Finding search engine for "{}"'.format(txt))
r = re.compile(r'(^|\s+)!(\w+)($|\s+)')
@ -69,7 +68,6 @@ def _is_url_naive(url):
Return:
True if the url really is an URL, False otherwise.
"""
PROTOCOLS = ['http://', 'https://']
u = urlstring(url)
@ -85,7 +83,6 @@ def _is_url_dns(url):
Return:
True if the url really is an URL, False otherwise.
"""
# FIXME we could probably solve this in a nicer way by attempting to open
# the page in the webview, and then open the search if that fails.
@ -109,7 +106,6 @@ def qurl(url):
Return:
The URL as string.
"""
return url if isinstance(url, QUrl) else QUrl(url)
@ -122,7 +118,6 @@ def urlstring(url):
Return:
The URL as string
"""
return url.toString() if isinstance(url, QUrl) else url
@ -135,7 +130,6 @@ def fuzzy_url(url):
Return:
A target QUrl to a searchpage or the original URL.
"""
u = qurl(url)
urlstr = urlstring(url)
@ -173,7 +167,6 @@ def is_url(url):
Raise:
ValueError if the autosearch config value is invalid.
"""
urlstr = urlstring(url)

View File

@ -32,7 +32,6 @@ class NeighborList:
_items: A list of all items, accessed through item property.
idx: The current position in the list.
_mode: The current mode.
"""
BLOCK = 0
@ -49,7 +48,6 @@ class NeighborList:
BLOCK: Stay on the selected item
WRAP: Wrap around to the other end
RAISE: Raise an IndexError.
"""
if items is None:
self._items = []
@ -78,7 +76,6 @@ class NeighborList:
Raise:
IndexError if the border of the list is reached and mode is RAISE.
"""
logging.debug("{} items, idx {}, offset {}".format(len(self._items),
self.idx, offset))

View File

@ -35,7 +35,6 @@ def _git_str():
Return:
string containing the git commit ID.
None if there was an error or we're not in a git repo.
"""
if hasattr(sys, "frozen"):
return None
@ -59,7 +58,6 @@ def _release_info():
Return:
list of (filename, content) tuples.
"""
data = []
for fn in glob.glob("/etc/*-release"):

View File

@ -33,7 +33,6 @@ class BrowserPage(QWebPage):
Attributes:
_extension_handlers: Mapping of QWebPage extensions to their handlers.
network_access_manager: The QNetworkAccessManager used.
"""
def __init__(self, parent=None):
@ -57,7 +56,6 @@ class BrowserPage(QWebPage):
Return:
False if no error page should be displayed, True otherwise.
"""
info = sip.cast(opt, QWebPage.ErrorPageExtensionOption)
errpage = sip.cast(out, QWebPage.ErrorPageExtensionReturn)
@ -79,7 +77,6 @@ class BrowserPage(QWebPage):
Return:
True if the extension can be handled, False otherwise.
"""
return ext in self._extension_handlers
@ -93,7 +90,6 @@ class BrowserPage(QWebPage):
Return:
Handler return value.
"""
try:
handler = self._extension_handlers[ext]

View File

@ -56,7 +56,6 @@ class BrowserTab(QWebView):
linkHovered: QWebPages linkHovered signal exposed.
temp_message: Show a temporary message in the statusbar.
arg: Message to be shown.
"""
scroll_pos_changed = pyqtSignal(int, int)
@ -93,7 +92,6 @@ class BrowserTab(QWebView):
Emit:
titleChanged and urlChanged
"""
u = urlutils.fuzzy_url(url)
logging.debug('New title: {}'.format(urlutils.urlstring(u)))
@ -109,7 +107,6 @@ class BrowserTab(QWebView):
Emit:
temp_message: Emitted with new zoom level.
"""
level = self._zoom.getitem(offset)
self.setZoomFactor(float(level) / 100)
@ -127,7 +124,6 @@ class BrowserTab(QWebView):
Emit:
open_tab: Emitted if window should be opened in a new tab.
"""
if self._open_new_tab:
self.open_tab.emit(url)
@ -143,7 +139,6 @@ class BrowserTab(QWebView):
Args:
callback: Function to call after shutting down.
"""
self._shutdown_callback = callback
try:
@ -176,7 +171,6 @@ class BrowserTab(QWebView):
Args:
sender: The object which called the callback.
"""
self._destroyed[sender] = True
dbgout = '\n'.join(['{}: {}'.format(k.__class__.__name__, v)
@ -200,7 +194,6 @@ class BrowserTab(QWebView):
Emit:
scroll_pos_changed; If the scroll position changed.
"""
frame = self.page_.mainFrame()
new_pos = (frame.scrollBarValue(Qt.Horizontal),
@ -230,7 +223,6 @@ class BrowserTab(QWebView):
Return:
The superclass event return value.
"""
if e.type() in [QEvent.MouseButtonPress, QEvent.MouseButtonDblClick]:
self._open_new_tab = (e.button() == Qt.MidButton or

View File

@ -19,7 +19,6 @@
Defines a CompletionView which uses CompletionFiterModel and CompletionModel
subclasses to provide completions.
"""
import logging
@ -68,7 +67,6 @@ class CompletionView(QTreeView):
Signals:
change_completed_part: Text which should be substituted for the word
we're currently completing.
"""
_STYLESHEET = """
@ -145,7 +143,6 @@ class CompletionView(QTreeView):
Return:
A QModelIndex.
"""
idx = self.selectionModel().currentIndex()
if not idx.isValid():
@ -166,7 +163,6 @@ class CompletionView(QTreeView):
"""Get a new completion model.
parts: The command chunks to get a completion for.
"""
if len(parts) == 1:
return 'command'
@ -196,7 +192,6 @@ class CompletionView(QTreeView):
Args:
model: An index into self._completion_models.
"""
self._lastmodel = self._model
m = self._completion_models[model]
@ -214,7 +209,6 @@ class CompletionView(QTreeView):
Args:
text: The new text
"""
# FIXME we should also consider the cursor position
if self._ignore_next:
@ -263,7 +257,6 @@ class CompletionView(QTreeView):
Emit:
change_completed_part: When a completion took place.
"""
if not self._completing:
# No completion running at the moment, ignore keypress
@ -292,7 +285,6 @@ class _CompletionItemDelegate(QStyledItemDelegate):
_style: The style to be used.
_painter: The QPainter to be used.
_doc: The QTextDocument to be used.
"""
# FIXME this is horribly slow when resizing.
@ -333,7 +325,6 @@ class _CompletionItemDelegate(QStyledItemDelegate):
Args:
index -- The QModelIndex of the item to draw.
"""
if not self._opt.text:
return
@ -381,7 +372,6 @@ class _CompletionItemDelegate(QStyledItemDelegate):
Args:
text_rect: The QRect to clip the drawing to.
"""
clip = QRectF(0, 0, text_rect.width(), text_rect.height())
self._doc.drawContents(self._painter, clip)
@ -391,7 +381,6 @@ class _CompletionItemDelegate(QStyledItemDelegate):
Args:
index: The QModelIndex of the item to draw.
"""
# FIXME we probably should do eliding here. See
# qcommonstyle.cpp:viewItemDrawText
@ -462,7 +451,6 @@ class _CompletionItemDelegate(QStyledItemDelegate):
Return:
A QSize with the recommended size.
"""
value = index.data(Qt.SizeHintRole)
if value is not None:
@ -483,7 +471,6 @@ class _CompletionItemDelegate(QStyledItemDelegate):
painter: QPainter * painter
option: const QStyleOptionViewItem & option
index: const QModelIndex & index
"""
self._painter = painter
self._painter.save()

View File

@ -39,7 +39,6 @@ class CrashDialog(QDialog):
_hbox: The QHboxLayout containing the buttons
_btn_quit: The quit button
_btn_restore: the restore button
"""
def __init__(self, pages, cmdhist, exc):
@ -49,7 +48,6 @@ class CrashDialog(QDialog):
pages: A list of the open pages (URLs as strings)
cmdhist: A list with the command history (as strings)
exc: An exception tuple (type, value, traceback)
"""
super().__init__()
self.setFixedSize(500, 350)
@ -99,7 +97,6 @@ class CrashDialog(QDialog):
Return:
The string to display.
"""
outputs = [
('Version info', version()),

View File

@ -40,7 +40,6 @@ class MainWindow(QWidget):
tabs: The TabbedBrowser widget.
status: The StatusBar widget.
_vbox: The main QVBoxLayout.
"""
def __init__(self):
@ -107,7 +106,6 @@ class MainWindow(QWidget):
Args:
e: The QResizeEvent
"""
super().resizeEvent(e)
confheight = str(config.config.get('general', 'completion_height'))

View File

@ -56,7 +56,6 @@ class StatusBar(QWidget):
moved: Emitted when the statusbar has moved, so the completion widget
can move the the right position.
arg: The new position.
"""
resized = pyqtSignal('QRect')
@ -131,7 +130,6 @@ class StatusBar(QWidget):
Re-set the stylesheet after setting the value, so everything gets
updated by Qt properly.
"""
self._error = val
self.setStyleSheet(get_stylesheet(self._STYLESHEET))
@ -163,7 +161,6 @@ class StatusBar(QWidget):
Args:
text: The text to display, or an empty string to clear.
"""
self.txt.temptext = text
@ -178,7 +175,6 @@ class StatusBar(QWidget):
Args:
e: The original QKeyEvent.
"""
if e.key() in [Qt.Key_Control, Qt.Key_Alt, Qt.Key_Shift, Qt.Key_Meta]:
# Only modifier pressed, don't hide yet.
@ -193,7 +189,6 @@ class StatusBar(QWidget):
Emit:
resized: Always emitted.
"""
super().resizeEvent(e)
self.resized.emit(self.geometry())
@ -206,7 +201,6 @@ class StatusBar(QWidget):
Emit:
moved: Always emitted.
"""
super().moveEvent(e)
self.moved.emit(e.pos())
@ -236,7 +230,6 @@ class _Command(QLineEdit):
hide_completion: Emitted when the completion widget should be hidden.
show_cmd: Emitted when command input should be shown.
hide_cmd: Emitted when command input can be hidden.
"""
# FIXME we should probably use a proper model for the command history.
@ -292,7 +285,6 @@ class _Command(QLineEdit):
Called when the user presses the up/down key and wasn't browsing the
history already.
"""
pre = self.text().strip()
logging.debug('Preset text: "{}"'.format(pre))
@ -349,7 +341,6 @@ class _Command(QLineEdit):
got_cmd: If a new cmd was entered.
got_search: If a new search was entered.
got_search_rev: If a new reverse search was entered.
"""
signals = {
':': self.got_cmd,
@ -370,7 +361,6 @@ class _Command(QLineEdit):
Args:
text: The text to set (string).
"""
self.setText(text)
self.setFocus()
@ -382,7 +372,6 @@ class _Command(QLineEdit):
Args:
text: The text to set (string).
"""
# FIXME we should consider the cursor position.
text = self.text()
@ -405,7 +394,6 @@ class _Command(QLineEdit):
Emit:
hide_completion: Always emitted so the completion is hidden.
"""
if e.reason() in [Qt.MouseFocusReason, Qt.TabFocusReason,
Qt.BacktabFocusReason, Qt.OtherFocusReason]:
@ -429,7 +417,6 @@ class _CommandValidator(QValidator):
Return:
A tuple (status, string, pos) as a QValidator should.
"""
if any(string.startswith(c) for c in keys.STARTCHARS):
return (QValidator.Acceptable, string, pos)
@ -443,7 +430,6 @@ class _Progress(QProgressBar):
Attributes:
_STYLESHEET: The stylesheet template.
"""
# FIXME for some reason, margin-left is not shown
@ -486,7 +472,6 @@ class TextBase(QLabel):
Attributes:
_elidemode: Where to elide the text.
_elided_text: The current elided text.
"""
def __init__(self, bar, elidemode=Qt.ElideRight):
@ -500,7 +485,6 @@ class TextBase(QLabel):
Args:
width: The maximal width the text should take.
"""
self._elided_text = self.fontMetrics().elidedText(
self.text(), self._elidemode, width, Qt.TextShowMnemonic)
@ -517,7 +501,6 @@ class TextBase(QLabel):
Args:
txt: The text to set (string).
"""
super().setText(txt)
self._update_elided_text(self.geometry().width())
@ -555,7 +538,6 @@ class _Text(TextBase):
when it is set. The temptext is shown when there is no error, and the
(permanent) text is shown when there is neither a temporary text nor an
error.
"""
def __init__(self, parent=None):
@ -576,7 +558,6 @@ class _Text(TextBase):
"""Update QLabel text when needed.
Called from __setattr__ if a text property changed.
"""
for text in [self.errortext, self.temptext, self.normaltext]:
if text:
@ -619,7 +600,6 @@ class _Percentage(TextBase):
Args:
_: The x percentage (int), currently ignored.
y: The y percentage (int)
"""
if y == 0:
self.setText('[top]')
@ -639,7 +619,6 @@ class _Url(TextBase):
_urltype: The current URL type. One of normal/ok/error/warn/hover.
Accessed via the urltype property.
_STYLESHEET: The stylesheet template.
"""
_STYLESHEET = """
@ -670,7 +649,6 @@ class _Url(TextBase):
Args:
bar: The statusbar (parent) object.
elidemode: How to elide the text.
"""
super().__init__(bar, elidemode)
self.setObjectName(self.__class__.__name__)
@ -697,7 +675,6 @@ class _Url(TextBase):
Args:
ok: Whether loading finished successfully (True) or not (False).
"""
# FIXME: set color to warn if there was an SSL error
self.urltype = 'success' if ok else 'error'
@ -708,7 +685,6 @@ class _Url(TextBase):
Args:
s: The URL to set.
"""
self.setText(urlstring(s))
self.urltype = 'normal'
@ -725,7 +701,6 @@ class _Url(TextBase):
link: The link which was hovered (string)
title: The title of the hovered link (string)
text: The text of the hovered link (string)
"""
if link:
if self._old_url is None:

View File

@ -31,7 +31,6 @@ class TabWidget(QTabWidget):
Attributes:
_STYLESHEET: The stylesheet template to be used.
"""
# FIXME there is still some ugly 1px white stripe from somewhere if we do

View File

@ -73,7 +73,6 @@ class TabbedBrowser(TabWidget):
resized: Emitted when the browser window has resized, so the completion
widget can adjust its size to it.
arg: The new size.
"""
cur_progress = pyqtSignal(int)
@ -112,7 +111,6 @@ class TabbedBrowser(TabWidget):
Emit:
shutdown_complete: When the tab shutdown is done completely.
"""
try:
self._tabs.remove(tab)
@ -133,7 +131,6 @@ class TabbedBrowser(TabWidget):
The current widget if count is None.
The widget with the given tab ID if count is given.
None if no widget was found.
"""
if count is None:
return self.currentWidget()
@ -149,7 +146,6 @@ class TabbedBrowser(TabWidget):
Args:
text: The text to set.
"""
logging.debug('title changed to "{}"'.format(text))
if text:
@ -165,7 +161,6 @@ class TabbedBrowser(TabWidget):
Return:
A partial functon calling _filter_signals with a signal.
"""
return functools.partial(self._filter_signals, signal)
@ -187,7 +182,6 @@ class TabbedBrowser(TabWidget):
Emit:
The target signal if the sender was the current widget.
"""
# FIXME BUG the signal cache ordering seems to be weird sometimes.
# How to reproduce:
@ -219,7 +213,6 @@ class TabbedBrowser(TabWidget):
Emit:
shutdown_complete if the shutdown completed successfully.
"""
try:
self.currentChanged.disconnect()
@ -248,7 +241,6 @@ class TabbedBrowser(TabWidget):
Emit:
quit: If last tab was closed and last_close in config is set to
quit.
"""
idx = self.currentIndex() if count is None else count - 1
tab = self.cntwidget(count)
@ -274,7 +266,6 @@ class TabbedBrowser(TabWidget):
Args:
url: The URL to open.
"""
logging.debug("Opening {}".format(url))
url = urlutils.qurl(url)
@ -306,7 +297,6 @@ class TabbedBrowser(TabWidget):
Emit:
set_cmd_text prefilled with :tabopen $URL
"""
url = urlutils.urlstring(self.currentWidget().url())
self.set_cmd_text.emit(':tabopen ' + url)
@ -317,7 +307,6 @@ class TabbedBrowser(TabWidget):
Emit:
set_cmd_text prefilled with :open $URL
"""
url = urlutils.urlstring(self.currentWidget().url())
self.set_cmd_text.emit(':open ' + url)
@ -327,7 +316,6 @@ class TabbedBrowser(TabWidget):
"""Switch to the previous tab, or skip [count] tabs.
Command handler for :undo.
"""
if self._url_stack:
self.tabopen(self._url_stack.pop())
@ -340,7 +328,6 @@ class TabbedBrowser(TabWidget):
Args:
count: How many tabs to switch back.
"""
idx = self.currentIndex()
if idx - count >= 0:
@ -357,7 +344,6 @@ class TabbedBrowser(TabWidget):
Args:
count: How many tabs to switch forward.
"""
idx = self.currentIndex()
if idx + count < self.count():
@ -374,7 +360,6 @@ class TabbedBrowser(TabWidget):
Args:
sel: True to use primary selection, False to use clipboard
"""
# FIXME what happens for invalid URLs?
clip = QApplication.clipboard()
@ -391,7 +376,6 @@ class TabbedBrowser(TabWidget):
Args:
sel: True to use primary selection, False to use clipboard
"""
# FIXME what happens for invalid URLs?
clip = QApplication.clipboard()
@ -408,7 +392,6 @@ class TabbedBrowser(TabWidget):
Emit:
keypress: Always emitted.
"""
self.keypress.emit(e)
super().keyPressEvent(e)
@ -421,7 +404,6 @@ class TabbedBrowser(TabWidget):
Emit:
resize: Always emitted.
"""
super().resizeEvent(e)
self.resized.emit(self.geometry())
@ -438,7 +420,6 @@ class CurCommandDispatcher(QObject):
Signals:
temp_message: Connected to TabbedBrowser signal.
"""
# FIXME maybe subclassing would be more clean?
@ -452,7 +433,6 @@ class CurCommandDispatcher(QObject):
Args:
parent: The TabbedBrowser for this dispatcher.
"""
super().__init__(parent)
self.tabs = parent
@ -464,7 +444,6 @@ class CurCommandDispatcher(QObject):
perc: How many percent to scroll, or None
count: How many percent to scroll, or None
orientation: Qt.Horizontal or Qt.Vertical
"""
if perc is None and count is None:
perc = 100
@ -488,7 +467,6 @@ class CurCommandDispatcher(QObject):
Args:
url: The URL to open.
count: The tab index to open the URL in, or None.
"""
tab = self.tabs.cntwidget(count)
if tab is None:
@ -510,7 +488,6 @@ class CurCommandDispatcher(QObject):
Args:
count: The tab index to reload, or None.
"""
tab = self.tabs.cntwidget(count)
if tab is not None:
@ -524,7 +501,6 @@ class CurCommandDispatcher(QObject):
Args:
count: The tab index to stop, or None.
"""
tab = self.tabs.cntwidget(count)
if tab is not None:
@ -538,7 +514,6 @@ class CurCommandDispatcher(QObject):
Args:
count: The tab index to print, or None.
"""
# FIXME that does not what I expect
tab = self.tabs.cntwidget(count)
@ -555,7 +530,6 @@ class CurCommandDispatcher(QObject):
Args:
count: How many pages to go back.
"""
# FIXME display warning if beginning of history
for i in range(count): # pylint: disable=unused-variable
@ -569,7 +543,6 @@ class CurCommandDispatcher(QObject):
Args:
count: How many pages to go forward.
"""
# FIXME display warning if end of history
for i in range(count): # pylint: disable=unused-variable
@ -582,7 +555,6 @@ class CurCommandDispatcher(QObject):
Args:
text: The text to search for.
flags: The QWebPage::FindFlags.
"""
self.tabs.currentWidget().findText(text, flags)
@ -596,7 +568,6 @@ class CurCommandDispatcher(QObject):
dx: How much to scroll in x-direction.
dy: How much to scroll in x-direction.
count: multiplier
"""
dx = int(count) * float(dx)
dy = int(count) * float(dy)
@ -612,7 +583,6 @@ class CurCommandDispatcher(QObject):
Args:
perc: Percentage to scroll.
count: Percentage to scroll.
"""
self._scroll_percent(perc, count, Qt.Horizontal)
@ -626,7 +596,6 @@ class CurCommandDispatcher(QObject):
Args:
perc: Percentage to scroll.
count: Percentage to scroll.
"""
self._scroll_percent(perc, count, Qt.Vertical)
@ -638,7 +607,6 @@ class CurCommandDispatcher(QObject):
mx: How many pages to scroll to the right.
my: How many pages to scroll down.
count: multiplier
"""
# FIXME this might not work with HTML frames
page = self.tabs.currentWidget().page_
@ -657,7 +625,6 @@ class CurCommandDispatcher(QObject):
Emit:
temp_message to display a temporary message.
"""
clip = QApplication.clipboard()
url = urlutils.urlstring(self.tabs.currentWidget().url())
@ -677,7 +644,6 @@ class CurCommandDispatcher(QObject):
Emit:
temp_message to display a temporary message.
"""
clip = QApplication.clipboard()
title = self.tabs.tabText(self.tabs.currentIndex())
@ -692,7 +658,6 @@ class CurCommandDispatcher(QObject):
Args:
count: How many steps to take.
"""
tab = self.tabs.currentWidget()
tab.zoom(count)
@ -703,7 +668,6 @@ class CurCommandDispatcher(QObject):
Args:
count: How many steps to take.
"""
tab = self.tabs.currentWidget()
tab.zoom(-count)

View File

@ -70,6 +70,7 @@ options = {
],
'pep257': [
'D102', # Docstring missing, will be handled by others
'D209', # Blank line before closing """ (removed from PEP257)
],
},
'exclude': ['appdirs.py'],