From d0979b9fac4ab531192822515d165467916c3eb1 Mon Sep 17 00:00:00 2001 From: Felix Van der Jeugt Date: Fri, 18 Dec 2015 23:40:44 +0100 Subject: [PATCH] fix pep8 and pylint errors Though I quite disagree on some remarks, as usual. --- qutebrowser/browser/hints.py | 37 ++++++++++++++++---------------- qutebrowser/config/configdata.py | 3 ++- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/qutebrowser/browser/hints.py b/qutebrowser/browser/hints.py index 8b5fb82f3..712b2ce5e 100644 --- a/qutebrowser/browser/hints.py +++ b/qutebrowser/browser/hints.py @@ -20,10 +20,8 @@ """A HintManager to draw hints over links.""" import collections -import itertools import functools import math -import os import re from string import ascii_lowercase @@ -39,7 +37,7 @@ from qutebrowser.keyinput import modeman, modeparsers from qutebrowser.browser import webelem from qutebrowser.commands import userscripts, cmdexc, cmdutils, runners from qutebrowser.utils import (usertypes, log, qtutils, message, - objreg, standarddir) + objreg) from qutebrowser.misc import guiprocess @@ -165,9 +163,10 @@ class HintManager(QObject): hints = set() lines = (line.rstrip().lower() for line in wordfile) for word in lines: - if not set(word) <= alphabet: + if set(word) - alphabet: + # contains none-alphabetic chars continue - if not len(word) <= 4: + if len(word) > 4: continue for i in range(len(word)): hints.discard(word[:i + 1]) @@ -254,21 +253,23 @@ class HintManager(QObject): Return: A list of hint strings, in the same order as the elements. """ - just_get_it = lambda tag: lambda elem: elem[tag] - take_last_part = lambda tag: lambda elem: elem[tag].split('/')[-1] - tag_extractors = { - "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"), - } + def just_get_it(tag): + return lambda elem: elem[tag] + + def take_last_part(tag): + return lambda elem: elem[tag].split('/')[-1] + + tag_extractors = dict( + 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, { - "IMG": ["alt", "title", "src"], - "A": ["title", "href"], - "INPUT": ["name"], - }) + "IMG": ["alt", "title", "src"], + "A": ["title", "href"], + "INPUT": ["name"]}) def extract_tag_words(elem): if elem.tagName() == "A": diff --git a/qutebrowser/config/configdata.py b/qutebrowser/config/configdata.py index 2ee19f652..40e2d83ed 100644 --- a/qutebrowser/config/configdata.py +++ b/qutebrowser/config/configdata.py @@ -864,7 +864,8 @@ def data(readonly=False): ('number', "Use numeric hints."), ('letter', "Use the chars in the hints -> " "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'), "Mode to use for hints."),