Load components dynamically
This commit is contained in:
parent
735e6123cd
commit
411c5171a2
@ -68,6 +68,7 @@ from qutebrowser.browser import (urlmarks, adblock, history, browsertab,
|
||||
from qutebrowser.browser.network import proxy
|
||||
from qutebrowser.browser.webkit import cookies, cache
|
||||
from qutebrowser.browser.webkit.network import networkmanager
|
||||
from qutebrowser.extensions import loader
|
||||
from qutebrowser.keyinput import macros
|
||||
from qutebrowser.mainwindow import mainwindow, prompt
|
||||
from qutebrowser.misc import (readline, ipc, savemanager, sessions,
|
||||
@ -77,8 +78,6 @@ from qutebrowser.utils import (log, version, message, utils, urlutils, objreg,
|
||||
usertypes, standarddir, error, qtutils)
|
||||
# pylint: disable=unused-import
|
||||
# We import those to run the cmdutils.register decorators.
|
||||
from qutebrowser.components import (scrollcommands, caretcommands,
|
||||
zoomcommands, misccommands)
|
||||
from qutebrowser.mainwindow.statusbar import command
|
||||
from qutebrowser.misc import utilcmds
|
||||
# pylint: enable=unused-import
|
||||
@ -166,6 +165,7 @@ def init(args, crash_handler):
|
||||
qApp.setQuitOnLastWindowClosed(False)
|
||||
_init_icon()
|
||||
|
||||
loader.load_components()
|
||||
try:
|
||||
_init_modules(args, crash_handler)
|
||||
except (OSError, UnicodeDecodeError, browsertab.WebTabError) as e:
|
||||
|
0
qutebrowser/extensions/__init__.py
Normal file
0
qutebrowser/extensions/__init__.py
Normal file
35
qutebrowser/extensions/loader.py
Normal file
35
qutebrowser/extensions/loader.py
Normal file
@ -0,0 +1,35 @@
|
||||
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
|
||||
|
||||
# Copyright 2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
|
||||
#
|
||||
# This file is part of qutebrowser.
|
||||
#
|
||||
# qutebrowser is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# qutebrowser is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
"""Loader for qutebrowser extensions."""
|
||||
|
||||
import pkgutil
|
||||
|
||||
from qutebrowser import components
|
||||
from qutebrowser.utils import log
|
||||
|
||||
|
||||
def load_components() -> None:
|
||||
"""Load everything from qutebrowser.components."""
|
||||
for info in pkgutil.walk_packages(components.__path__):
|
||||
if info.ispkg:
|
||||
continue
|
||||
log.extensions.debug("Importing {}".format(info.name))
|
||||
loader = info.module_finder.find_module(info.name)
|
||||
loader.load_module(info.name)
|
@ -137,6 +137,7 @@ prompt = logging.getLogger('prompt')
|
||||
network = logging.getLogger('network')
|
||||
sql = logging.getLogger('sql')
|
||||
greasemonkey = logging.getLogger('greasemonkey')
|
||||
extensions = logging.getLogger('extensions')
|
||||
|
||||
LOGGER_NAMES = [
|
||||
'statusbar', 'completion', 'init', 'url',
|
||||
@ -146,7 +147,7 @@ LOGGER_NAMES = [
|
||||
'js', 'qt', 'rfc6266', 'ipc', 'shlexer',
|
||||
'save', 'message', 'config', 'sessions',
|
||||
'webelem', 'prompt', 'network', 'sql',
|
||||
'greasemonkey'
|
||||
'greasemonkey', 'extensions',
|
||||
]
|
||||
|
||||
|
||||
|
@ -30,6 +30,7 @@ import argparse
|
||||
import vulture
|
||||
|
||||
import qutebrowser.app # pylint: disable=unused-import
|
||||
from qutebrowser.extensions import loader
|
||||
from qutebrowser.misc import objects
|
||||
from qutebrowser.utils import utils
|
||||
from qutebrowser.browser.webkit import rfc6266
|
||||
@ -43,6 +44,8 @@ from qutebrowser.config import configtypes
|
||||
|
||||
def whitelist_generator(): # noqa
|
||||
"""Generator which yields lines to add to a vulture whitelist."""
|
||||
loader.load_components()
|
||||
|
||||
# qutebrowser commands
|
||||
for cmd in objects.commands.values():
|
||||
yield utils.qualname(cmd.handler)
|
||||
|
@ -35,6 +35,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir,
|
||||
# We import qutebrowser.app so all @cmdutils-register decorators are run.
|
||||
import qutebrowser.app
|
||||
from qutebrowser import qutebrowser, commands
|
||||
from qutebrowser.extensions import loader
|
||||
from qutebrowser.commands import argparser
|
||||
from qutebrowser.config import configdata, configtypes
|
||||
from qutebrowser.utils import docutils, usertypes
|
||||
@ -549,6 +550,7 @@ def regenerate_cheatsheet():
|
||||
def main():
|
||||
"""Regenerate all documentation."""
|
||||
utils.change_cwd()
|
||||
loader.load_components()
|
||||
print("Generating manpage...")
|
||||
regenerate_manpage('doc/qutebrowser.1.asciidoc')
|
||||
print("Generating settings help...")
|
||||
|
Loading…
Reference in New Issue
Block a user