当前位置: 首页>>代码示例>>Python>>正文


Python cmdutils.check_exclusive函数代码示例

本文整理汇总了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;未经允许,请勿转载。