Fix up mistakes caught by pylint.

This commit is contained in:
Ryan Roden-Corrent 2016-04-12 22:00:29 -04:00
parent 84eb30bc9a
commit c7b830d69d
2 changed files with 16 additions and 14 deletions

View File

@ -1890,7 +1890,7 @@ class CommandDispatcher:
@cmdutils.register(instance='command-dispatcher', scope='window')
def set_mark(self, key):
"""Set a mark at the current scroll position in the current tab
"""Set a mark at the current scroll position in the current tab.
Args:
key: mark identifier; capital indicates a global mark
@ -1911,13 +1911,13 @@ class CommandDispatcher:
@cmdutils.register(instance='command-dispatcher', scope='window')
def jump_mark(self, key):
"""Jump to the mark named by `key`
"""Jump to the mark named by `key`.
Args:
key: mark identifier; capital indicates a global mark
"""
# consider urls that differ only in fragment to be identical
cur_url = self._current_url().adjusted(QUrl.RemoveFragment)
urlkey = self._current_url().adjusted(QUrl.RemoveFragment)
if key.isupper() and key in self._global_marks:
# y is a pixel position relative to the top of the page
@ -1930,12 +1930,12 @@ class CommandDispatcher:
self.openurl(url.toString())
self._tabbed_browser.cur_load_finished.connect(callback)
elif cur_url in self._local_marks and key in self._local_marks[cur_url]:
y = self._local_marks[cur_url][key]
elif urlkey in self._local_marks and key in self._local_marks[urlkey]:
y = self._local_marks[urlkey][key]
# save the pre-jump position in the special ' mark
# this has to happen after we read the mark, otherwise jump_mark "'"
# would just jump to the current position every time
# this has to happen after we read the mark, otherwise jump_mark
# "'" would just jump to the current position every time
self.set_mark("'")
self._scroll_px_absolute(y)
@ -1943,10 +1943,11 @@ class CommandDispatcher:
message.error(self._win_id, "Mark {} is not set".format(key))
def _current_y_px(self):
"""Return the current y scroll position in pixels from the top"""
return self._current_widget().page().currentFrame().scrollPosition().y()
"""Return the current y scroll position in pixels from the top."""
frame = self._current_widget().page().currentFrame()
return frame.scrollPosition().y()
def _scroll_px_absolute(self, y):
"""Scroll to the position y pixels from the top of the page"""
"""Scroll to the position y pixels from the top of the page."""
self.scroll('top')
self.scroll_px(0, y)

View File

@ -25,7 +25,7 @@ Module attributes:
from PyQt5.QtCore import pyqtSlot, Qt
from qutebrowser.utils import utils, message
from qutebrowser.utils import message
from qutebrowser.config import config
from qutebrowser.keyinput import keyparser, modeman
from qutebrowser.utils import usertypes, log, objreg, utils
@ -231,6 +231,7 @@ class CaretKeyParser(keyparser.CommandKeyParser):
supports_chains=True)
self.read_config('caret')
class MarkKeyParser(keyparser.CommandKeyParser):
"""KeyParser for set_mark and jump_mark mode.
@ -245,7 +246,7 @@ class MarkKeyParser(keyparser.CommandKeyParser):
self._mode = mode
def handle(self, e):
"""Override handle to always match the next key and create a mark
"""Override handle to always match the next key and create a mark.
Args:
e: the KeyPressEvent from Qt.
@ -256,7 +257,7 @@ class MarkKeyParser(keyparser.CommandKeyParser):
if utils.keyevent_to_string(e) is None:
# this is a modifier key, let it pass and keep going
return True;
return True
if not e.text().isalpha() and e.text() != "'":
# only valid mark names are [a-zA-Z']
@ -268,7 +269,7 @@ class MarkKeyParser(keyparser.CommandKeyParser):
elif self._mode == usertypes.KeyMode.jump_mark:
self._commandrunner.run('jump-mark "{}"'.format(e.text()))
else:
raise ValueError("{} is not a valid mark mode".format(mode))
raise ValueError("{} is not a valid mark mode".format(self._mode))
modeman.leave(self._win_id, self._mode, "valid mark key")