本文整理汇总了Python中qutebrowser.utils.objreg.delete函数的典型用法代码示例。如果您正苦于以下问题:Python delete函数的具体用法?Python delete怎么用?Python delete使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了delete函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: download_stub
def download_stub(win_registry):
"""Register a FakeDownloadManager."""
stub = FakeDownloadManager()
objreg.register('download-manager', stub,
scope='window', window='last-focused')
yield
objreg.delete('download-manager', scope='window', window='last-focused')
开发者ID:djfinlay,项目名称:qutebrowser,代码行数:7,代码来源:test_adblock.py
示例2: status_command_stub
def status_command_stub(stubs, qtbot, win_registry):
"""Fixture which provides a fake status-command object."""
cmd = stubs.StatusBarCommandStub()
objreg.register('status-command', cmd, scope='window', window=0)
qtbot.addWidget(cmd)
yield cmd
objreg.delete('status-command', scope='window', window=0)
开发者ID:julianuu,项目名称:qutebrowser,代码行数:7,代码来源:fixtures.py
示例3: fake_keyconfig
def fake_keyconfig():
"""Create a mock of a KeyConfiguration and register it into objreg."""
fake_keyconfig = mock.Mock(spec=['get_bindings_for'])
fake_keyconfig.get_bindings_for.side_effect = lambda s: BINDINGS[s]
objreg.register('key-config', fake_keyconfig)
yield
objreg.delete('key-config')
开发者ID:baskervald,项目名称:qutebrowser,代码行数:7,代码来源:test_basekeyparser.py
示例4: default_config
def default_config():
"""Fixture that provides and registers an empty default config object."""
config_obj = config.ConfigManager()
config_obj.read(configdir=None, fname=None, relaxed=True)
objreg.register('config', config_obj)
yield config_obj
objreg.delete('config')
开发者ID:spiderbit,项目名称:qutebrowser,代码行数:7,代码来源:fixtures.py
示例5: _remove_tab
def _remove_tab(self, tab):
"""Remove a tab from the tab list and delete it properly.
Args:
tab: The QWebView to be closed.
"""
idx = self.indexOf(tab)
if idx == -1:
raise ValueError("tab {} is not contained in TabbedWidget!".format(
tab))
if tab is self._now_focused:
self._now_focused = None
if tab is objreg.get('last-focused-tab', None, scope='window',
window=self._win_id):
objreg.delete('last-focused-tab', scope='window',
window=self._win_id)
if tab.cur_url.isValid():
history_data = qtutils.serialize(tab.history())
entry = UndoEntry(tab.cur_url, history_data)
self._undo_stack.append(entry)
elif tab.cur_url.isEmpty():
# There are some good reasons why an URL could be empty
# (target="_blank" with a download, see [1]), so we silently ignore
# this.
# [1] https://github.com/The-Compiler/qutebrowser/issues/163
pass
else:
# We display a warnings for URLs which are not empty but invalid -
# but we don't return here because we want the tab to close either
# way.
urlutils.invalid_url_error(self._win_id, tab.cur_url, "saving tab")
tab.shutdown()
self.removeTab(idx)
tab.deleteLater()
开发者ID:HalosGhost,项目名称:qutebrowser,代码行数:34,代码来源:tabbedbrowser.py
示例6: fake_args
def fake_args(request):
ns = types.SimpleNamespace()
ns.backend = 'webengine' if request.config.webengine else 'webkit'
ns.debug_flags = []
objreg.register('args', ns)
yield ns
objreg.delete('args')
开发者ID:fiete201,项目名称:qutebrowser,代码行数:7,代码来源:fixtures.py
示例7: _remove_tab
def _remove_tab(self, tab):
"""Remove a tab from the tab list and delete it properly.
Args:
tab: The QWebView to be closed.
Raise:
ValueError if the tab is not in the QTabWidget.
"""
idx = self.indexOf(tab)
if idx == -1:
raise ValueError("tab {} is not contained in TabbedWidget!".format(
tab))
if tab is self._now_focused:
self._now_focused = None
if tab is objreg.get('last-focused-tab', None):
objreg.delete('last-focused-tab')
if not tab.cur_url.isEmpty():
qtutils.ensure_valid(tab.cur_url)
history_data = qtutils.serialize(tab.history())
entry = UndoEntry(tab.cur_url, history_data)
self._undo_stack.append(entry)
tab.shutdown()
self._tabs.remove(tab)
self.removeTab(idx)
tab.deleteLater()
开发者ID:har5ha,项目名称:qutebrowser,代码行数:26,代码来源:tabbedbrowser.py
示例8: test_init
def test_init(backend, qapp, tmpdir, monkeypatch, fake_save_manager,
fake_args):
if backend == 'webkit':
pytest.importorskip('PyQt5.QtWebKitWidgets')
fake_args.backend = backend
monkeypatch.setattr(history.standarddir, 'data', lambda: str(tmpdir))
history.init(qapp)
hist = objreg.get('web-history')
assert hist.parent() is qapp
try:
from PyQt5.QtWebKit import QWebHistoryInterface
except ImportError:
QWebHistoryInterface = None
if backend == 'webkit':
default_interface = QWebHistoryInterface.defaultInterface()
assert default_interface._history is hist
else:
assert backend == 'webengine'
if QWebHistoryInterface is None:
default_interface = None
else:
default_interface = QWebHistoryInterface.defaultInterface()
# For this to work, nothing can ever have called setDefaultInterface
# before (so we need to test webengine before webkit)
assert default_interface is None
assert fake_save_manager.add_saveable.called
objreg.delete('web-history')
开发者ID:NoctuaNivalis,项目名称:qutebrowser,代码行数:31,代码来源:test_history.py
示例9: web_history
def web_history(init_sql, stubs, config_stub):
"""Fixture which provides a web-history object."""
config_stub.val.completion.timestamp_format = '%Y-%m-%d'
config_stub.val.completion.web_history_max_items = -1
stub = history.WebHistory()
objreg.register('web-history', stub)
yield stub
objreg.delete('web-history')
开发者ID:nanjekyejoannah,项目名称:qutebrowser,代码行数:8,代码来源:test_models.py
示例10: web_history
def web_history(fake_save_manager, tmpdir, init_sql, config_stub, stubs):
"""Create a web history and register it into objreg."""
config_stub.val.completion.timestamp_format = '%Y-%m-%d'
config_stub.val.completion.web_history.max_items = -1
web_history = history.WebHistory(stubs.FakeHistoryProgress())
objreg.register('web-history', web_history)
yield web_history
objreg.delete('web-history')
开发者ID:fiete201,项目名称:qutebrowser,代码行数:8,代码来源:fixtures.py
示例11: fake_keyconfig
def fake_keyconfig():
"""Create a mock of a KeyConfiguration and register it into objreg."""
bindings = dict(BINDINGS) # so the bindings can be changed later
fake_keyconfig = mock.Mock(spec=['get_bindings_for'])
fake_keyconfig.get_bindings_for.side_effect = lambda s: bindings[s]
objreg.register('key-config', fake_keyconfig)
yield bindings
objreg.delete('key-config')
开发者ID:michaelbeaumont,项目名称:qutebrowser,代码行数:8,代码来源:conftest.py
示例12: test_init
def test_init(qapp, tmpdir, monkeypatch, fake_save_manager):
monkeypatch.setattr(history.standarddir, 'data', lambda: str(tmpdir))
history.init(qapp)
hist = objreg.get('web-history')
assert hist.parent() is qapp
assert QWebHistoryInterface.defaultInterface()._history is hist
assert fake_save_manager.add_saveable.called
objreg.delete('web-history')
开发者ID:Swoorup,项目名称:qutebrowser,代码行数:8,代码来源:test_history.py
示例13: tabbed_browser_stubs
def tabbed_browser_stubs(stubs, win_registry):
"""Fixture providing a fake tabbed-browser object on win_id 0 and 1."""
win_registry.add_window(1)
stubs = [stubs.TabbedBrowserStub(), stubs.TabbedBrowserStub()]
objreg.register('tabbed-browser', stubs[0], scope='window', window=0)
objreg.register('tabbed-browser', stubs[1], scope='window', window=1)
yield stubs
objreg.delete('tabbed-browser', scope='window', window=0)
objreg.delete('tabbed-browser', scope='window', window=1)
开发者ID:forkbong,项目名称:qutebrowser,代码行数:9,代码来源:fixtures.py
示例14: cookiejar_and_cache
def cookiejar_and_cache(stubs):
"""Fixture providing a fake cookie jar and cache."""
jar = QNetworkCookieJar()
cache = stubs.FakeNetworkCache()
objreg.register('cookie-jar', jar)
objreg.register('cache', cache)
yield
objreg.delete('cookie-jar')
objreg.delete('cache')
开发者ID:derlaft,项目名称:qutebrowser,代码行数:9,代码来源:conftest.py
示例15: _remove_tab
def _remove_tab(self, tab, *, add_undo=True, new_undo=True, crashed=False):
"""Remove a tab from the tab list and delete it properly.
Args:
tab: The QWebView to be closed.
add_undo: Whether the tab close can be undone.
new_undo: Whether the undo entry should be a new item in the stack.
crashed: Whether we're closing a tab with crashed renderer process.
"""
idx = self.widget.indexOf(tab)
if idx == -1:
if crashed:
return
raise TabDeletedError("tab {} is not contained in "
"TabbedWidget!".format(tab))
if tab is self._now_focused:
self._now_focused = None
if tab is objreg.get('last-focused-tab', None, scope='window',
window=self._win_id):
objreg.delete('last-focused-tab', scope='window',
window=self._win_id)
if tab.url().isEmpty():
# There are some good reasons why a URL could be empty
# (target="_blank" with a download, see [1]), so we silently ignore
# this.
# [1] https://github.com/qutebrowser/qutebrowser/issues/163
pass
elif not tab.url().isValid():
# We display a warning for URLs which are not empty but invalid -
# but we don't return here because we want the tab to close either
# way.
urlutils.invalid_url_error(tab.url(), "saving tab")
elif add_undo:
try:
history_data = tab.history.serialize()
except browsertab.WebTabError:
pass # special URL
else:
entry = UndoEntry(tab.url(), history_data, idx,
tab.data.pinned)
if new_undo or not self._undo_stack:
self._undo_stack.append([entry])
else:
self._undo_stack[-1].append(entry)
tab.shutdown()
self.widget.removeTab(idx)
if not crashed:
# WORKAROUND for a segfault when we delete the crashed tab.
# see https://bugreports.qt.io/browse/QTBUG-58698
tab.layout().unwrap()
tab.deleteLater()
开发者ID:mehak,项目名称:qutebrowser,代码行数:53,代码来源:tabbedbrowser.py
示例16: setup
def setup(self, mocker, stubs):
"""Set up mocks and read the test config."""
mocker.patch('qutebrowser.keyinput.basekeyparser.usertypes.Timer',
new=stubs.FakeTimer)
mocker.patch('qutebrowser.keyinput.modeparsers.config',
new=stubs.ConfigStub(CONFIG))
objreg.register('key-config', fake_keyconfig)
self.kp = modeparsers.NormalKeyParser(0)
self.kp.execute = mock.Mock()
yield
objreg.delete('key-config')
开发者ID:baskervald,项目名称:qutebrowser,代码行数:12,代码来源:test_modeparsers.py
示例17: _do_close
def _do_close(self):
"""Helper function for closeEvent."""
try:
last_visible = objreg.get('last-visible-main-window')
if self is last_visible:
objreg.delete('last-visible-main-window')
except KeyError:
pass
objreg.get('session-manager').save_last_window_session()
self._save_geometry()
log.destroy.debug("Closing window {}".format(self.win_id))
self.tabbed_browser.shutdown()
开发者ID:shaggytwodope,项目名称:qutebrowser,代码行数:12,代码来源:mainwindow.py
示例18: cleanup_init
def cleanup_init():
# prevent test_init from leaking state
yield
hist = objreg.get('web-history', None)
if hist is not None:
hist.setParent(None)
objreg.delete('web-history')
try:
from PyQt5.QtWebKit import QWebHistoryInterface
QWebHistoryInterface.setDefaultInterface(None)
except ImportError:
pass
开发者ID:blyxxyz,项目名称:qutebrowser,代码行数:12,代码来源:test_history.py
示例19: on_focus_changed
def on_focus_changed(self, _old, new):
"""Register currently focused main window in the object registry."""
if new is None:
window = None
else:
window = new.window()
if window is None or not isinstance(window, mainwindow.MainWindow):
try:
objreg.delete('last-focused-main-window')
except KeyError:
pass
else:
objreg.register('last-focused-main-window', window, update=True)
开发者ID:pyrho,项目名称:qutebrowser,代码行数:13,代码来源:app.py
示例20: init_patch
def init_patch(qapp, fake_save_manager, monkeypatch, config_tmpdir,
data_tmpdir):
monkeypatch.setattr(configfiles, 'state', None)
monkeypatch.setattr(config, 'instance', None)
monkeypatch.setattr(config, 'key_instance', None)
monkeypatch.setattr(config, 'change_filters', [])
monkeypatch.setattr(configinit, '_init_errors', None)
monkeypatch.setattr(configtypes.Font, 'monospace_fonts', None)
yield
try:
objreg.delete('config-commands')
except KeyError:
pass
开发者ID:nanjekyejoannah,项目名称:qutebrowser,代码行数:13,代码来源:test_configinit.py
注:本文中的qutebrowser.utils.objreg.delete函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论