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


Python qtutils.version_check函数代码示例

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


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

示例1: _parse_yaml_backends_dict

def _parse_yaml_backends_dict(name, node):
    """Parse a dict definition for backends.

    Example:

    backends:
      QtWebKit: true
      QtWebEngine: Qt 5.9
    """
    str_to_backend = {
        'QtWebKit': usertypes.Backend.QtWebKit,
        'QtWebEngine': usertypes.Backend.QtWebEngine,
    }

    if node.keys() != str_to_backend.keys():
        _raise_invalid_node(name, 'backends', node)

    backends = []

    # The value associated to the key, and whether we should add that backend
    # or not.
    conditionals = {
        True: True,
        False: False,
        'Qt 5.8': qtutils.version_check('5.8'),
        'Qt 5.9': qtutils.version_check('5.9'),
    }
    for key in sorted(node.keys()):
        if conditionals[node[key]]:
            backends.append(str_to_backend[key])

    return backends
开发者ID:swalladge,项目名称:qutebrowser,代码行数:32,代码来源:configdata.py

示例2: _qtwebengine_args

def _qtwebengine_args() -> typing.Iterator[str]:
    """Get the QtWebEngine arguments to use based on the config."""
    if not qtutils.version_check('5.11', compiled=False):
        # WORKAROUND equivalent to
        # https://codereview.qt-project.org/#/c/217932/
        # Needed for Qt < 5.9.5 and < 5.10.1
        yield '--disable-shared-workers'

    settings = {
        'qt.force_software_rendering': {
            'software-opengl': None,
            'qt-quick': None,
            'chromium': '--disable-gpu',
            'none': None,
        },
        'content.canvas_reading': {
            True: None,
            False: '--disable-reading-from-canvas',
        },
        'content.webrtc_ip_handling_policy': {
            'all-interfaces': None,
            'default-public-and-private-interfaces':
                '--force-webrtc-ip-handling-policy='
                'default_public_and_private_interfaces',
            'default-public-interface-only':
                '--force-webrtc-ip-handling-policy='
                'default_public_interface_only',
            'disable-non-proxied-udp':
                '--force-webrtc-ip-handling-policy='
                'disable_non_proxied_udp',
        },
        'qt.process_model': {
            'process-per-site-instance': None,
            'process-per-site': '--process-per-site',
            'single-process': '--single-process',
        },
        'qt.low_end_device_mode': {
            'auto': None,
            'always': '--enable-low-end-device-mode',
            'never': '--disable-low-end-device-mode',
        },
        'content.headers.referer': {
            'always': None,
            'never': '--no-referrers',
            'same-domain': '--reduced-referrer-granularity',
        }
    }  # type: typing.Dict[str, typing.Dict[typing.Any, typing.Optional[str]]]

    if not qtutils.version_check('5.11'):
        # On Qt 5.11, we can control this via QWebEngineSettings
        settings['content.autoplay'] = {
            True: None,
            False: '--autoplay-policy=user-gesture-required',
        }

    for setting, args in sorted(settings.items()):
        arg = args[config.instance.get(setting)]
        if arg is not None:
            yield arg
开发者ID:The-Compiler,项目名称:qutebrowser,代码行数:59,代码来源:configinit.py

示例3: _on_load_started

 def _on_load_started(self):
     """Clear search when a new load is started if needed."""
     if (qtutils.version_check('5.9') and
             not qtutils.version_check('5.9.2')):
         # WORKAROUND for
         # https://bugreports.qt.io/browse/QTBUG-61506
         self.search.clear()
     super()._on_load_started()
开发者ID:michaelbeaumont,项目名称:qutebrowser,代码行数:8,代码来源:webenginetab.py

示例4: install

    def install(self, profile):
        """Install the handler for qute:// URLs on the given profile."""
        if QWebEngineUrlScheme is not None:
            assert QWebEngineUrlScheme.schemeByName(b'qute') is not None

        profile.installUrlSchemeHandler(b'qute', self)
        if (qtutils.version_check('5.11', compiled=False) and
                not qtutils.version_check('5.12', compiled=False)):
            # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-63378
            profile.installUrlSchemeHandler(b'chrome-error', self)
            profile.installUrlSchemeHandler(b'chrome-extension', self)
开发者ID:The-Compiler,项目名称:qutebrowser,代码行数:11,代码来源:webenginequtescheme.py

示例5: check_qt_version

def check_qt_version(args):
    """Check if the Qt version is recent enough."""
    from PyQt5.QtCore import qVersion
    from qutebrowser.utils import qtutils
    if qtutils.version_check('5.2.0', operator.lt):
        text = ("Fatal error: Qt and PyQt >= 5.2.0 are required, but {} is "
                "installed.".format(qVersion()))
        _die(text)
    elif args.backend == 'webengine' and qtutils.version_check('5.6.0',
                                                               operator.lt):
        text = ("Fatal error: Qt and PyQt >= 5.6.0 are required for "
                "QtWebEngine support, but {} is installed.".format(qVersion()))
        _die(text)
开发者ID:shioyama,项目名称:qutebrowser,代码行数:13,代码来源:earlyinit.py

示例6: _apply_platform_markers

def _apply_platform_markers(config, item):
    """Apply a skip marker to a given item."""
    markers = [
        ('posix', not utils.is_posix, "Requires a POSIX os"),
        ('windows', not utils.is_windows, "Requires Windows"),
        ('linux', not utils.is_linux, "Requires Linux"),
        ('mac', not utils.is_mac, "Requires macOS"),
        ('not_mac', utils.is_mac, "Skipped on macOS"),
        ('not_frozen', getattr(sys, 'frozen', False),
         "Can't be run when frozen"),
        ('frozen', not getattr(sys, 'frozen', False),
         "Can only run when frozen"),
        ('ci', not ON_CI, "Only runs on CI."),
        ('no_ci', ON_CI, "Skipped on CI."),
        ('issue2478', utils.is_windows and config.webengine,
         "Broken with QtWebEngine on Windows"),
        ('issue3572',
         (qtutils.version_check('5.10', compiled=False, exact=True) or
          qtutils.version_check('5.10.1', compiled=False, exact=True)) and
         config.webengine and 'TRAVIS' in os.environ,
         "Broken with QtWebEngine with Qt 5.10 on Travis"),
        ('qtbug60673',
         qtutils.version_check('5.8') and
         not qtutils.version_check('5.10') and
         config.webengine,
         "Broken on webengine due to "
         "https://bugreports.qt.io/browse/QTBUG-60673"),
        ('unicode_locale', sys.getfilesystemencoding() == 'ascii',
         "Skipped because of ASCII locale"),
        ('qtwebkit6021_skip',
         version.qWebKitVersion and
         version.qWebKitVersion() == '602.1',
         "Broken on WebKit 602.1")
    ]

    for searched_marker, condition, default_reason in markers:
        marker = item.get_closest_marker(searched_marker)
        if not marker or not condition:
            continue

        if 'reason' in marker.kwargs:
            reason = '{}: {}'.format(default_reason, marker.kwargs['reason'])
            del marker.kwargs['reason']
        else:
            reason = default_reason + '.'
        skipif_marker = pytest.mark.skipif(condition, *marker.args,
                                           reason=reason, **marker.kwargs)
        item.add_marker(skipif_marker)
开发者ID:mehak,项目名称:qutebrowser,代码行数:48,代码来源:conftest.py

示例7: init

def init(args):
    """Initialize the global QWebSettings."""
    if args.enable_webengine_inspector:
        os.environ['QTWEBENGINE_REMOTE_DEBUGGING'] = str(utils.random_port())

    # Workaround for a black screen with some setups
    # https://github.com/spyder-ide/spyder/issues/3226
    if not os.environ.get('QUTE_NO_OPENGL_WORKAROUND'):
        # Hide "No OpenGL_accelerate module loaded: ..." message
        logging.getLogger('OpenGL.acceleratesupport').propagate = False
        try:
            from OpenGL import GL  # pylint: disable=unused-variable
        except ImportError:
            pass
        else:
            log.misc.debug("Imported PyOpenGL as workaround")

    _init_profiles()

    # We need to do this here as a WORKAROUND for
    # https://bugreports.qt.io/browse/QTBUG-58650
    if not qtutils.version_check('5.9'):
        PersistentCookiePolicy().set(config.get('content', 'cookies-store'))
    Attribute(QWebEngineSettings.FullScreenSupportEnabled).set(True)

    websettings.init_mappings(MAPPINGS)
    objreg.get('config').changed.connect(update_settings)
开发者ID:phansch,项目名称:qutebrowser,代码行数:27,代码来源:webenginesettings.py

示例8: init

def init():
    """Disable insecure SSL ciphers on old Qt versions."""
    if not qtutils.version_check("5.3.0"):
        # Disable weak SSL ciphers.
        # See https://codereview.qt-project.org/#/c/75943/
        good_ciphers = [c for c in QSslSocket.supportedCiphers() if c.usedBits() >= 128]
        QSslSocket.setDefaultCiphers(good_ciphers)
开发者ID:xu-fengfeng,项目名称:qutebrowser,代码行数:7,代码来源:networkmanager.py

示例9: __init__

    def __init__(self, *, win_id, private, parent=None):
        if private:
            assert not qtutils.is_single_process()
        super().__init__(parent)
        self.widget = tabwidget.TabWidget(win_id, parent=self)
        self._win_id = win_id
        self._tab_insert_idx_left = 0
        self._tab_insert_idx_right = -1
        self.shutting_down = False
        self.widget.tabCloseRequested.connect(self.on_tab_close_requested)
        self.widget.new_tab_requested.connect(self.tabopen)
        self.widget.currentChanged.connect(self.on_current_changed)
        self.cur_fullscreen_requested.connect(self.widget.tabBar().maybe_hide)
        self.widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)

        # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-65223
        if qtutils.version_check('5.10', compiled=False):
            self.cur_load_finished.connect(self._leave_modes_on_load)
        else:
            self.cur_load_started.connect(self._leave_modes_on_load)

        self._undo_stack = []
        self._filter = signalfilter.SignalFilter(win_id, self)
        self._now_focused = None
        self.search_text = None
        self.search_options = {}
        self._local_marks = {}
        self._global_marks = {}
        self.default_window_icon = self.widget.window().windowIcon()
        self.is_private = private
        config.instance.changed.connect(self._on_config_changed)
开发者ID:The-Compiler,项目名称:qutebrowser,代码行数:31,代码来源:tabbedbrowser.py

示例10: inject_userscripts

def inject_userscripts():
    """Register user JavaScript files with the global profiles."""
    # The Greasemonkey metadata block support in QtWebEngine only starts at
    # Qt 5.8. With 5.7.1, we need to inject the scripts ourselves in response
    # to urlChanged.
    if not qtutils.version_check('5.8'):
        return

    # Since we are inserting scripts into profile.scripts they won't
    # just get replaced by new gm scripts like if we were injecting them
    # ourselves so we need to remove all gm scripts, while not removing
    # any other stuff that might have been added. Like the one for
    # stylesheets.
    greasemonkey = objreg.get('greasemonkey')
    for profile in [default_profile, private_profile]:
        scripts = profile.scripts()
        for script in scripts.toList():
            if script.name().startswith("GM-"):
                log.greasemonkey.debug('Removing script: {}'
                                       .format(script.name()))
                removed = scripts.remove(script)
                assert removed, script.name()

        # Then add the new scripts.
        for script in greasemonkey.all_scripts():
            # @run-at (and @include/@exclude/@match) is parsed by
            # QWebEngineScript.
            new_script = QWebEngineScript()
            new_script.setWorldId(QWebEngineScript.MainWorld)
            new_script.setSourceCode(script.code())
            new_script.setName("GM-{}".format(script.name))
            new_script.setRunsOnSubFrames(script.runs_on_sub_frames)
            log.greasemonkey.debug('adding script: {}'
                                   .format(new_script.name()))
            scripts.insert(new_script)
开发者ID:Harrison97,项目名称:qutebrowser,代码行数:35,代码来源:webenginesettings.py

示例11: eventFilter

    def eventFilter(self, obj, event):
        """Act on ChildAdded events."""
        if event.type() == QEvent.ChildAdded:
            child = event.child()
            log.mouse.debug("{} got new child {}, installing filter".format(
                obj, child))
            assert obj is self._widget
            child.installEventFilter(self._filter)

            if qtutils.version_check('5.11', compiled=False, exact=True):
                # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-68076
                pass_modes = [usertypes.KeyMode.command,
                              usertypes.KeyMode.prompt,
                              usertypes.KeyMode.yesno]
                if modeman.instance(self._win_id).mode not in pass_modes:
                    tabbed_browser = objreg.get('tabbed-browser',
                                                scope='window',
                                                window=self._win_id)
                    current_index = tabbed_browser.widget.currentIndex()
                    try:
                        widget_index = tabbed_browser.widget.indexOf(
                            self._widget.parent())
                    except RuntimeError:
                        widget_index = -1
                    if current_index == widget_index:
                        QTimer.singleShot(0, self._widget.setFocus)

        elif event.type() == QEvent.ChildRemoved:
            child = event.child()
            log.mouse.debug("{}: removed child {}".format(obj, child))

        return False
开发者ID:The-Compiler,项目名称:qutebrowser,代码行数:32,代码来源:mouse.py

示例12: __init__

    def __init__(self, *, win_id, tab_id, tab, private, parent=None):
        super().__init__(parent)
        if sys.platform == 'darwin' and qtutils.version_check('5.4'):
            # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-42948
            # See https://github.com/qutebrowser/qutebrowser/issues/462
            self.setStyle(QStyleFactory.create('Fusion'))
        # FIXME:qtwebengine this is only used to set the zoom factor from
        # the QWebPage - we should get rid of it somehow (signals?)
        self.tab = tab
        self._tabdata = tab.data
        self.win_id = win_id
        self.scroll_pos = (-1, -1)
        self._old_scroll_pos = (-1, -1)
        self._set_bg_color()
        self._tab_id = tab_id

        page = webpage.BrowserPage(win_id=self.win_id, tab_id=self._tab_id,
                                   tabdata=tab.data, private=private,
                                   parent=self)

        try:
            page.setVisibilityState(
                QWebPage.VisibilityStateVisible if self.isVisible()
                else QWebPage.VisibilityStateHidden)
        except AttributeError:
            pass

        self.setPage(page)

        mode_manager = objreg.get('mode-manager', scope='window',
                                  window=win_id)
        mode_manager.entered.connect(self.on_mode_entered)
        mode_manager.left.connect(self.on_mode_left)
        objreg.get('config').changed.connect(self._set_bg_color)
开发者ID:michaelbeaumont,项目名称:qutebrowser,代码行数:34,代码来源:webview.py

示例13: install

 def install(self, profile):
     """Install the handler for qute:// URLs on the given profile."""
     profile.installUrlSchemeHandler(b'qute', self)
     if qtutils.version_check('5.11', compiled=False):
         # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-63378
         profile.installUrlSchemeHandler(b'chrome-error', self)
         profile.installUrlSchemeHandler(b'chrome-extension', self)
开发者ID:mehak,项目名称:qutebrowser,代码行数:7,代码来源:webenginequtescheme.py

示例14: pytest_collection_modifyitems

def pytest_collection_modifyitems(config, items):
    """Apply @qtwebengine_* markers; skip unittests with QUTE_BDD_WEBENGINE."""
    vercheck = qtutils.version_check
    qtbug_54419_fixed = ((vercheck('5.6.2') and not vercheck('5.7.0')) or
                         qtutils.version_check('5.7.1') or
                         os.environ.get('QUTE_QTBUG54419_PATCHED', ''))

    markers = [
        ('qtwebengine_createWindow', 'Skipped because of QTBUG-54419',
         pytest.mark.skipif, not qtbug_54419_fixed and config.webengine),
        ('qtwebengine_todo', 'QtWebEngine TODO', pytest.mark.xfail,
         config.webengine),
        ('qtwebengine_skip', 'Skipped with QtWebEngine', pytest.mark.skipif,
         config.webengine),
        ('qtwebkit_skip', 'Skipped with QtWebKit', pytest.mark.skipif,
         not config.webengine),
        ('qtwebengine_flaky', 'Flaky with QtWebEngine', pytest.mark.skipif,
         config.webengine),
        ('qtwebengine_osx_xfail', 'Fails on OS X with QtWebEngine',
         pytest.mark.xfail, config.webengine and sys.platform == 'darwin'),
    ]

    for item in items:
        for name, prefix, pytest_mark, condition in markers:
            marker = item.get_marker(name)
            if marker and condition:
                if marker.args:
                    text = '{}: {}'.format(prefix, marker.args[0])
                else:
                    text = prefix
                item.add_marker(pytest_mark(condition, reason=text,
                                            **marker.kwargs))
开发者ID:Dietr1ch,项目名称:qutebrowser,代码行数:32,代码来源:conftest.py

示例15: dictionary_dir

def dictionary_dir(old=False):
    """Return the path (str) to the QtWebEngine's dictionaries directory."""
    if qtutils.version_check('5.10', compiled=False) and not old:
        datapath = standarddir.data()
    else:
        datapath = QLibraryInfo.location(QLibraryInfo.DataPath)
    return os.path.join(datapath, 'qtwebengine_dictionaries')
开发者ID:mehak,项目名称:qutebrowser,代码行数:7,代码来源:spell.py


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