Add api.config.get

This commit is contained in:
Florian Bruhin 2018-12-10 14:55:28 +01:00
parent 1b1872e464
commit 58d179302e
2 changed files with 10 additions and 6 deletions

View File

@ -21,11 +21,15 @@
import typing
MYPY = False
if MYPY:
# pylint: disable=unused-import,useless-suppression
from qutebrowser.config import config
from PyQt5.QtCore import QUrl
from qutebrowser.config import config
# pylint: disable=unused-import
from qutebrowser.config.config import change_filter
val = typing.cast('config.ConfigContainer', None)
def get(name: str, url: QUrl = None) -> typing.Any:
"""Get a value from the config based on a string name."""
return config.instance.get(name, url)

View File

@ -112,8 +112,8 @@ class HostBlocker:
"""Check if the given URL (as QUrl) is blocked."""
if first_party_url is not None and not first_party_url.isValid():
first_party_url = None
if not config.instance.get('content.host_blocking.enabled',
url=first_party_url):
if not config.get('content.host_blocking.enabled',
url=first_party_url):
return False
host = url.host()