Make webkitelem/mhtml imports optional in commands

This commit is contained in:
Florian Bruhin 2016-09-05 18:20:48 +02:00
parent bf3cccfe56
commit 3b8537ff26

View File

@ -44,7 +44,13 @@ from qutebrowser.commands import userscripts, cmdexc, cmdutils, runners
from qutebrowser.config import config, configexc
from qutebrowser.browser import (urlmarks, browsertab, inspector, navigate,
webelem)
from qutebrowser.browser.webkit import webkitelem, downloads, mhtml
from qutebrowser.browser.webkit import downloads
try:
from qutebrowser.browser.webkit import webkitelem, mhtml
except ImportError:
# Failing imports on QtWebEngine, only used in QtWebKit commands.
# FIXME:qtwebengine don't import this anymore at all
pass
from qutebrowser.keyinput import modeman
from qutebrowser.utils import (message, usertypes, log, qtutils, urlutils,
objreg, utils, typing, javascript)
@ -1493,8 +1499,8 @@ class CommandDispatcher:
"""
try:
elem.set_text(text, use_js=True)
except webkitelem.IsNullError:
raise cmdexc.CommandError("Element vanished while editing!")
except webelem.Error as e:
raise cmdexc.CommandError(str(e))
@cmdutils.register(instance='command-dispatcher',
deprecated="Use :insert-text {primary}",