Add missing docstrings
This commit is contained in:
parent
03a339b93a
commit
3f9ded3bed
@ -487,6 +487,7 @@ class AbstractHistory:
|
||||
raise NotImplementedError
|
||||
|
||||
def back(self, count=1):
|
||||
"""Go back in the tab's history."""
|
||||
idx = self.current_idx() - count
|
||||
if idx >= 0:
|
||||
self._go_to_item(self._item_at(idx))
|
||||
@ -495,6 +496,7 @@ class AbstractHistory:
|
||||
raise WebTabError("At beginning of history.")
|
||||
|
||||
def forward(self, count=1):
|
||||
"""Go forward in the tab's history."""
|
||||
idx = self.current_idx() + count
|
||||
if idx < len(self):
|
||||
self._go_to_item(self._item_at(idx))
|
||||
|
@ -1522,6 +1522,7 @@ class CommandDispatcher:
|
||||
dest = os.path.expanduser(dest)
|
||||
|
||||
def callback(data):
|
||||
"""Write the data to disk."""
|
||||
try:
|
||||
with open(dest, 'w', encoding='utf-8') as f:
|
||||
f.write(data)
|
||||
@ -2040,6 +2041,7 @@ class CommandDispatcher:
|
||||
jseval_cb = None
|
||||
else:
|
||||
def jseval_cb(out):
|
||||
"""Show the data returned from JS."""
|
||||
if out is None:
|
||||
# Getting the actual error (if any) seems to be difficult.
|
||||
# The error does end up in
|
||||
|
@ -268,6 +268,7 @@ class WebHistory(sql.SqlTable):
|
||||
return
|
||||
|
||||
def action():
|
||||
"""Actually run the import."""
|
||||
with debug.log_time(log.init, 'Import old history file to sqlite'):
|
||||
try:
|
||||
self._read(path)
|
||||
|
@ -94,6 +94,7 @@ class AbstractWebInspector(QWidget):
|
||||
raise NotImplementedError
|
||||
|
||||
def toggle(self, page):
|
||||
"""Show/hide the inspector."""
|
||||
if self._widget.isVisible():
|
||||
self.hide()
|
||||
else:
|
||||
|
@ -59,6 +59,7 @@ def _js_slot(*args):
|
||||
def _decorator(method):
|
||||
@functools.wraps(method)
|
||||
def new_method(self, *args, **kwargs):
|
||||
"""Call the underlying function."""
|
||||
try:
|
||||
return method(self, *args, **kwargs)
|
||||
except:
|
||||
|
@ -113,6 +113,7 @@ class add_handler: # noqa: N801,N806 pylint: disable=invalid-name
|
||||
return function
|
||||
|
||||
def wrapper(self, *args, **kwargs):
|
||||
"""Call the underlying function."""
|
||||
if self._backend is not None and objects.backend != self._backend:
|
||||
return self.wrong_backend_handler(*args, **kwargs)
|
||||
else:
|
||||
|
@ -226,6 +226,7 @@ class WebEngineElement(webelem.AbstractWebElement):
|
||||
QEventLoop.ExcludeUserInputEvents)
|
||||
|
||||
def reset_setting(_arg):
|
||||
"""Set the JavascriptCanOpenWindows setting to its old value."""
|
||||
try:
|
||||
view.settings().setAttribute(attribute, could_open_windows)
|
||||
except RuntimeError:
|
||||
|
@ -542,6 +542,7 @@ class WebKitElements(browsertab.AbstractElements):
|
||||
|
||||
def find_id(self, elem_id, callback):
|
||||
def find_id_cb(elems):
|
||||
"""Call the real callback with the found elements."""
|
||||
if not elems:
|
||||
callback(None)
|
||||
else:
|
||||
|
@ -104,11 +104,13 @@ class change_filter: # noqa: N801,N806 pylint: disable=invalid-name
|
||||
if self._function:
|
||||
@functools.wraps(func)
|
||||
def wrapper(option=None):
|
||||
"""Call the underlying function."""
|
||||
if self._check_match(option):
|
||||
return func()
|
||||
else:
|
||||
@functools.wraps(func)
|
||||
def wrapper(wrapper_self, option=None):
|
||||
"""Call the underlying function."""
|
||||
if self._check_match(option):
|
||||
return func(wrapper_self)
|
||||
|
||||
|
@ -83,6 +83,7 @@ class NormalKeyParser(keyparser.CommandKeyParser):
|
||||
return match
|
||||
|
||||
def set_inhibited_timeout(self, timeout):
|
||||
"""Ignore keypresses for the given duration."""
|
||||
if timeout != 0:
|
||||
self._debug_log("Inhibiting the normal mode for {}ms.".format(
|
||||
timeout))
|
||||
|
@ -818,6 +818,7 @@ class TabbedBrowser(tabwidget.TabWidget):
|
||||
point, url = self._global_marks[key]
|
||||
|
||||
def callback(ok):
|
||||
"""Scroll once loading finished."""
|
||||
if ok:
|
||||
self.cur_load_finished.disconnect(callback)
|
||||
tab.scroller.to_point(point)
|
||||
|
@ -364,6 +364,7 @@ def _check_backend_modules():
|
||||
|
||||
|
||||
def init():
|
||||
"""Check for various issues related to QtWebKit/QtWebEngine."""
|
||||
_check_backend_modules()
|
||||
if objects.backend == usertypes.Backend.QtWebEngine:
|
||||
_handle_ssl_support()
|
||||
|
@ -261,6 +261,7 @@ def init_log(args):
|
||||
|
||||
|
||||
def check_optimize_flag():
|
||||
"""Check whether qutebrowser is running with -OO."""
|
||||
from qutebrowser.utils import log
|
||||
if sys.flags.optimize >= 2:
|
||||
log.init.warning("Running on optimize level higher than 1, "
|
||||
|
@ -266,6 +266,7 @@ class log_time: # noqa: N801,N806 pylint: disable=invalid-name
|
||||
def __call__(self, func):
|
||||
@functools.wraps(func)
|
||||
def wrapped(*args, **kwargs):
|
||||
"""Call the original function."""
|
||||
with self:
|
||||
func(*args, **kwargs)
|
||||
|
||||
|
@ -216,6 +216,7 @@ class GlobalMessageBridge(QObject):
|
||||
self.ask_question.emit(question, blocking)
|
||||
|
||||
def show(self, level, text, replace=False):
|
||||
"""Show the given message."""
|
||||
if self._connected:
|
||||
self.show_message.emit(level, text, replace)
|
||||
else:
|
||||
|
@ -631,6 +631,7 @@ class prevent_exceptions: # noqa: N801,N806 pylint: disable=invalid-name
|
||||
|
||||
@functools.wraps(func)
|
||||
def wrapper(*args, **kwargs):
|
||||
"""Call the original function."""
|
||||
try:
|
||||
return func(*args, **kwargs)
|
||||
except BaseException:
|
||||
|
@ -66,6 +66,7 @@ class AsciiDoc:
|
||||
shutil.rmtree(self._homedir)
|
||||
|
||||
def build(self):
|
||||
"""Build either the website or the docs."""
|
||||
if self._args.website:
|
||||
self._build_website()
|
||||
else:
|
||||
|
@ -40,6 +40,7 @@ def print_header():
|
||||
|
||||
|
||||
def print_paths():
|
||||
"""Print all QStandardPaths.StandardLocation members."""
|
||||
for name, obj in vars(QStandardPaths).items():
|
||||
if isinstance(obj, QStandardPaths.StandardLocation):
|
||||
location = QStandardPaths.writableLocation(obj)
|
||||
|
@ -233,6 +233,7 @@ def install(languages):
|
||||
|
||||
|
||||
def update(languages):
|
||||
"""Update the given languages."""
|
||||
installed = [lang for lang in languages if lang.local_version is not None]
|
||||
for lang in installed:
|
||||
if lang.local_version < lang.remote_version:
|
||||
@ -244,6 +245,7 @@ def update(languages):
|
||||
|
||||
|
||||
def remove_old(languages):
|
||||
"""Remove old versions of languages."""
|
||||
installed = [lang for lang in languages if lang.local_version is not None]
|
||||
for lang in installed:
|
||||
local_files = spell.local_files(lang.code)
|
||||
|
@ -332,6 +332,7 @@ def import_chrome(profile, bookmark_types, output_format):
|
||||
bookmarks = json.load(f)
|
||||
|
||||
def bm_tree_walk(bm, template):
|
||||
"""Recursive function to walk through bookmarks."""
|
||||
assert 'type' in bm, bm
|
||||
if bm['type'] == 'url':
|
||||
if urllib.parse.urlparse(bm['url']).scheme != 'chrome':
|
||||
|
Loading…
Reference in New Issue
Block a user