fix pep8 and pylint errors
Though I quite disagree on some remarks, as usual.
This commit is contained in:
parent
4814abe286
commit
d0979b9fac
@ -20,10 +20,8 @@
|
|||||||
"""A HintManager to draw hints over links."""
|
"""A HintManager to draw hints over links."""
|
||||||
|
|
||||||
import collections
|
import collections
|
||||||
import itertools
|
|
||||||
import functools
|
import functools
|
||||||
import math
|
import math
|
||||||
import os
|
|
||||||
import re
|
import re
|
||||||
from string import ascii_lowercase
|
from string import ascii_lowercase
|
||||||
|
|
||||||
@ -39,7 +37,7 @@ from qutebrowser.keyinput import modeman, modeparsers
|
|||||||
from qutebrowser.browser import webelem
|
from qutebrowser.browser import webelem
|
||||||
from qutebrowser.commands import userscripts, cmdexc, cmdutils, runners
|
from qutebrowser.commands import userscripts, cmdexc, cmdutils, runners
|
||||||
from qutebrowser.utils import (usertypes, log, qtutils, message,
|
from qutebrowser.utils import (usertypes, log, qtutils, message,
|
||||||
objreg, standarddir)
|
objreg)
|
||||||
from qutebrowser.misc import guiprocess
|
from qutebrowser.misc import guiprocess
|
||||||
|
|
||||||
|
|
||||||
@ -165,9 +163,10 @@ class HintManager(QObject):
|
|||||||
hints = set()
|
hints = set()
|
||||||
lines = (line.rstrip().lower() for line in wordfile)
|
lines = (line.rstrip().lower() for line in wordfile)
|
||||||
for word in lines:
|
for word in lines:
|
||||||
if not set(word) <= alphabet:
|
if set(word) - alphabet:
|
||||||
|
# contains none-alphabetic chars
|
||||||
continue
|
continue
|
||||||
if not len(word) <= 4:
|
if len(word) > 4:
|
||||||
continue
|
continue
|
||||||
for i in range(len(word)):
|
for i in range(len(word)):
|
||||||
hints.discard(word[:i + 1])
|
hints.discard(word[:i + 1])
|
||||||
@ -254,21 +253,23 @@ class HintManager(QObject):
|
|||||||
Return:
|
Return:
|
||||||
A list of hint strings, in the same order as the elements.
|
A list of hint strings, in the same order as the elements.
|
||||||
"""
|
"""
|
||||||
just_get_it = lambda tag: lambda elem: elem[tag]
|
def just_get_it(tag):
|
||||||
take_last_part = lambda tag: lambda elem: elem[tag].split('/')[-1]
|
return lambda elem: elem[tag]
|
||||||
tag_extractors = {
|
|
||||||
"alt": just_get_it("alt"),
|
def take_last_part(tag):
|
||||||
"title": just_get_it("title"),
|
return lambda elem: elem[tag].split('/')[-1]
|
||||||
"src": take_last_part("src"),
|
|
||||||
"href": take_last_part("href"),
|
tag_extractors = dict(
|
||||||
"name": just_get_it("name"),
|
alt=just_get_it("alt"),
|
||||||
}
|
title=just_get_it("title"),
|
||||||
|
src=take_last_part("src"),
|
||||||
|
href=take_last_part("href"),
|
||||||
|
name=just_get_it("name"))
|
||||||
|
|
||||||
tags_for = collections.defaultdict(list, {
|
tags_for = collections.defaultdict(list, {
|
||||||
"IMG": ["alt", "title", "src"],
|
"IMG": ["alt", "title", "src"],
|
||||||
"A": ["title", "href"],
|
"A": ["title", "href"],
|
||||||
"INPUT": ["name"],
|
"INPUT": ["name"]})
|
||||||
})
|
|
||||||
|
|
||||||
def extract_tag_words(elem):
|
def extract_tag_words(elem):
|
||||||
if elem.tagName() == "A":
|
if elem.tagName() == "A":
|
||||||
|
@ -864,7 +864,8 @@ def data(readonly=False):
|
|||||||
('number', "Use numeric hints."),
|
('number', "Use numeric hints."),
|
||||||
('letter', "Use the chars in the hints -> "
|
('letter', "Use the chars in the hints -> "
|
||||||
"chars setting."),
|
"chars setting."),
|
||||||
('word', "Use hints words based on the html elements and the extra words."),
|
('word', "Use hints words based on the html "
|
||||||
|
"elements and the extra words."),
|
||||||
)), 'letter'),
|
)), 'letter'),
|
||||||
"Mode to use for hints."),
|
"Mode to use for hints."),
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user