• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python cmdutils.check_exclusive函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中qutebrowser.commands.cmdutils.check_exclusive函数的典型用法代码示例。如果您正苦于以下问题:Python check_exclusive函数的具体用法?Python check_exclusive怎么用?Python check_exclusive使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了check_exclusive函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _get_selection_override

    def _get_selection_override(self, left, right, opposite):
        """Helper function for tab_close to get the tab to select.

        Args:
            left: Force selecting the tab to the left of the current tab.
            right: Force selecting the tab to the right of the current tab.
            opposite: Force selecting the tab in the oppsite direction of
                      what's configured in 'tabs->select-on-remove'.

        Return:
            QTabBar.SelectLeftTab, QTabBar.SelectRightTab, or None if no change
            should be made.
        """
        cmdutils.check_exclusive((left, right, opposite), 'lro')
        if left:
            return QTabBar.SelectLeftTab
        elif right:
            return QTabBar.SelectRightTab
        elif opposite:
            conf_selection = config.get('tabs', 'select-on-remove')
            if conf_selection == QTabBar.SelectLeftTab:
                return QTabBar.SelectRightTab
            elif conf_selection == QTabBar.SelectRightTab:
                return QTabBar.SelectLeftTab
            elif conf_selection == QTabBar.SelectPreviousTab:
                raise cmdexc.CommandError(
                    "-o is not supported with 'tabs->select-on-remove' set to "
                    "'previous'!")
        return None
开发者ID:helenst,项目名称:qutebrowser,代码行数:29,代码来源:commands.py


示例2: _open

    def _open(self, url, tab, background, window):
        """Helper function to open a page.

        Args:
            url: The URL to open as QUrl.
            tab: Whether to open in a new tab.
            background: Whether to open in the background.
            window: Whether to open in a new window
        """
        if not url.isValid():
            errstr = "Invalid URL {}"
            if url.errorString():
                errstr += " - {}".format(url.errorString())
            raise cmdexc.CommandError(errstr)
        tabbed_browser = self._tabbed_browser()
        cmdutils.check_exclusive((tab, background, window), 'tbw')
        if window:
            tabbed_browser = self._tabbed_browser(window=True)
            tabbed_browser.tabopen(url)
        elif tab:
            tabbed_browser.tabopen(url, background=False, explicit=True)
        elif background:
            tabbed_browser.tabopen(url, background=True, explicit=True)
        else:
            widget = self._current_widget()
            widget.openurl(url)
开发者ID:pyrho,项目名称:qutebrowser,代码行数:26,代码来源:commands.py


示例3: tab_only

    def tab_only(self, left=False, right=False):
        """Close all tabs except for the current one.

        Args:
            left: Keep tabs to the left of the current.
            right: Keep tabs to the right of the current.
        """
        cmdutils.check_exclusive((left, right), 'lr')
        tabbed_browser = self._tabbed_browser()
        cur_idx = tabbed_browser.currentIndex()
        assert cur_idx != -1

        for i, tab in enumerate(tabbed_browser.widgets()):
            if (i == cur_idx or (left and i < cur_idx) or
                    (right and i > cur_idx)):
                continue
            else:
                tabbed_browser.close_tab(tab)
开发者ID:helenst,项目名称:qutebrowser,代码行数:18,代码来源:commands.py


示例4: navigate

    def navigate(self, where: {'type': ('prev', 'next', 'up', 'increment',
                                        'decrement')},
                 tab=False, bg=False, window=False):
        """Open typical prev/next links or navigate using the URL path.

        This tries to automatically click on typical _Previous Page_ or
        _Next Page_ links using some heuristics.

        Alternatively it can navigate by changing the current URL.

        Args:
            where: What to open.

                - `prev`: Open a _previous_ link.
                - `next`: Open a _next_ link.
                - `up`: Go up a level in the current URL.
                - `increment`: Increment the last number in the URL.
                - `decrement`: Decrement the last number in the URL.

            tab: Open in a new tab.
            bg: Open in a background tab.
            window: Open in a new window.
        """
        cmdutils.check_exclusive((tab, bg, window), 'tbw')
        widget = self._current_widget()
        frame = widget.page().currentFrame()
        url = self._current_url()
        if frame is None:
            raise cmdexc.CommandError("No frame focused!")
        hintmanager = objreg.get('hintmanager', scope='tab')
        if where == 'prev':
            hintmanager.follow_prevnext(frame, url, prev=True, tab=tab,
                                        background=bg, window=window)
        elif where == 'next':
            hintmanager.follow_prevnext(frame, url, prev=False, tab=tab,
                                        background=bg, window=window)
        elif where == 'up':
            self._navigate_up(url, tab, bg, window)
        elif where in ('decrement', 'increment'):
            self._navigate_incdec(url, where, tab, bg, window)
        else:
            raise ValueError("Got called with invalid value {} for "
                             "`where'.".format(where))
开发者ID:helenst,项目名称:qutebrowser,代码行数:43,代码来源:commands.py


示例5: _open

    def _open(self, url, tab, background, window):
        """Helper function to open a page.

        Args:
            url: The URL to open as QUrl.
            tab: Whether to open in a new tab.
            background: Whether to open in the background.
            window: Whether to open in a new window
        """
        urlutils.raise_cmdexc_if_invalid(url)
        tabbed_browser = self._tabbed_browser()
        cmdutils.check_exclusive((tab, background, window), 'tbw')
        if window:
            tabbed_browser = self._tabbed_browser(window=True)
            tabbed_browser.tabopen(url)
        elif tab:
            tabbed_browser.tabopen(url, background=False, explicit=True)
        elif background:
            tabbed_browser.tabopen(url, background=True, explicit=True)
        else:
            widget = self._current_widget()
            widget.openurl(url)
开发者ID:helenst,项目名称:qutebrowser,代码行数:22,代码来源:commands.py


示例6: test_bad

 def test_bad(self):
     with pytest.raises(cmdexc.CommandError,
                        match="Only one of -x/-y/-z can be given!"):
         cmdutils.check_exclusive([True, True], 'xyz')
开发者ID:blyxxyz,项目名称:qutebrowser,代码行数:4,代码来源:test_cmdutils.py


示例7: test_good

 def test_good(self, flags):
     cmdutils.check_exclusive(flags, [])
开发者ID:blyxxyz,项目名称:qutebrowser,代码行数:2,代码来源:test_cmdutils.py


示例8: test_bad

    def test_bad(self):
        with pytest.raises(cmdexc.CommandError) as excinfo:
            cmdutils.check_exclusive([True, True], 'xyz')

        assert str(excinfo.value) == "Only one of -x/-y/-z can be given!"
开发者ID:addictedtoflames,项目名称:qutebrowser,代码行数:5,代码来源:test_cmdutils.py



注:本文中的qutebrowser.commands.cmdutils.check_exclusive函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python cmdutils.check_overflow函数代码示例发布时间:2022-05-26
下一篇:
Python webelem.javascript_escape函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap