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


Python message.info函数代码示例

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


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

示例1: import_txt

    def import_txt(self):
        """Import a history text file into sqlite if it exists.

        In older versions of qutebrowser, history was stored in a text format.
        This converts that file into the new sqlite format and moves it to a
        backup location.
        """
        path = os.path.join(standarddir.data(), 'history')
        if not os.path.isfile(path):
            return

        def action():
            with debug.log_time(log.init, 'Import old history file to sqlite'):
                try:
                    self._read(path)
                except ValueError as ex:
                    message.error('Failed to import history: {}'.format(ex))
                else:
                    bakpath = path + '.bak'
                    message.info('History import complete. Moving {} to {}'
                                 .format(path, bakpath))
                    os.rename(path, bakpath)

        # delay to give message time to appear before locking down for import
        message.info('Converting {} to sqlite...'.format(path))
        QTimer.singleShot(100, action)
开发者ID:swalladge,项目名称:qutebrowser,代码行数:26,代码来源:history.py

示例2: session_save

    def session_save(self, name: str = default, current=False, quiet=False,
                     force=False, only_active_window=False, with_private=False,
                     win_id=None):
        """Save a session.

        Args:
            name: The name of the session. If not given, the session configured
                  in general -> session-default-name is saved.
            current: Save the current session instead of the default.
            quiet: Don't show confirmation message.
            force: Force saving internal sessions (starting with an underline).
            only_active_window: Saves only tabs of the currently active window.
            with_private: Include private windows.
        """
        if name is not default and name.startswith('_') and not force:
            raise cmdexc.CommandError("{} is an internal session, use --force "
                                      "to save anyways.".format(name))
        if current:
            if self._current is None:
                raise cmdexc.CommandError("No session loaded currently!")
            name = self._current
            assert not name.startswith('_')
        try:
            if only_active_window:
                name = self.save(name, only_window=win_id,
                                 with_private=with_private)
            else:
                name = self.save(name, with_private=with_private)
        except SessionError as e:
            raise cmdexc.CommandError("Error while saving session: {}"
                                      .format(e))
        else:
            if not quiet:
                message.info("Saved session {}.".format(name))
开发者ID:phansch,项目名称:qutebrowser,代码行数:34,代码来源:sessions.py

示例3: _handle_wheel

    def _handle_wheel(self, e):
        """Zoom on Ctrl-Mousewheel.

        Args:
            e: The QWheelEvent.
        """
        if self._ignore_wheel_event:
            # See https://github.com/qutebrowser/qutebrowser/issues/395
            self._ignore_wheel_event = False
            return True

        if e.modifiers() & Qt.ControlModifier:
            divider = config.get('input', 'mouse-zoom-divider')
            if divider == 0:
                return False
            factor = self._tab.zoom.factor() + (e.angleDelta().y() / divider)
            if factor < 0:
                return False
            perc = int(100 * factor)
            message.info("Zoom level: {}%".format(perc), replace=True)
            self._tab.zoom.set_factor(factor)
        elif e.modifiers() & Qt.ShiftModifier:
            if e.angleDelta().y() > 0:
                self._tab.scroller.left()
            else:
                self._tab.scroller.right()
            return True

        return False
开发者ID:michaelbeaumont,项目名称:qutebrowser,代码行数:29,代码来源:mouse.py

示例4: session_save

    def session_save(self, win_id, name: {'type': str}=default, current=False,
                     quiet=False, force=False):
        """Save a session.

        Args:
            win_id: The current window ID.
            name: The name of the session. If not given, the session configured
                  in general -> session-default-name is saved.
            current: Save the current session instead of the default.
            quiet: Don't show confirmation message.
            force: Force saving internal sessions (starting with an underline).
        """
        if (name is not default and
                name.startswith('_') and  # pylint: disable=no-member
                not force):
            raise cmdexc.CommandError("{} is an internal session, use --force "
                                      "to save anyways.".format(name))
        if current:
            if self._current is None:
                raise cmdexc.CommandError("No session loaded currently!")
            name = self._current
            assert not name.startswith('_')
        try:
            name = self.save(name)
        except SessionError as e:
            raise cmdexc.CommandError("Error while saving session: {}"
                                      .format(e))
        else:
            if not quiet:
                message.info(win_id, "Saved session {}.".format(name),
                             immediately=True)
开发者ID:a2batic,项目名称:qutebrowser,代码行数:31,代码来源:sessions.py

示例5: on_finished

    def on_finished(self, code, status):
        """Show a message when the process finished."""
        self._started = False
        log.procs.debug("Process finished with code {}, status {}.".format(
            code, status))
        if status == QProcess.CrashExit:
            message.error(self._win_id,
                          "{} crashed!".format(self._what.capitalize()),
                          immediately=True)
        elif status == QProcess.NormalExit and code == 0:
            if self.verbose:
                message.info(self._win_id, "{} exited successfully.".format(
                    self._what.capitalize()))
        else:
            assert status == QProcess.NormalExit
            # We call this 'status' here as it makes more sense to the user -
            # it's actually 'code'.
            message.error(self._win_id, "{} exited with status {}.".format(
                self._what.capitalize(), code))

            stderr = bytes(self._proc.readAllStandardError()).decode('utf-8')
            stdout = bytes(self._proc.readAllStandardOutput()).decode('utf-8')
            if stdout:
                log.procs.error("Process stdout:\n" + stdout.strip())
            if stderr:
                log.procs.error("Process stderr:\n" + stderr.strip())
开发者ID:bcb,项目名称:qutebrowser,代码行数:26,代码来源:guiprocess.py

示例6: _on_finished

    def _on_finished(self, code, status):
        """Show a message when the process finished."""
        self._started = False
        log.procs.debug("Process finished with code {}, status {}.".format(
            code, status))

        encoding = locale.getpreferredencoding(do_setlocale=False)
        stderr = bytes(self._proc.readAllStandardError()).decode(
            encoding, 'replace')
        stdout = bytes(self._proc.readAllStandardOutput()).decode(
            encoding, 'replace')

        if status == QProcess.CrashExit:
            exitinfo = "{} crashed!".format(self._what.capitalize())
            message.error(exitinfo)
        elif status == QProcess.NormalExit and code == 0:
            exitinfo = "{} exited successfully.".format(
                self._what.capitalize())
            if self.verbose:
                message.info(exitinfo)
        else:
            assert status == QProcess.NormalExit
            # We call this 'status' here as it makes more sense to the user -
            # it's actually 'code'.
            exitinfo = ("{} exited with status {}, see :messages for "
                        "details.").format(self._what.capitalize(), code)
            message.error(exitinfo)

            if stdout:
                log.procs.error("Process stdout:\n" + stdout.strip())
            if stderr:
                log.procs.error("Process stderr:\n" + stderr.strip())

        qutescheme.spawn_output = self._spawn_format(exitinfo, stdout, stderr)
开发者ID:The-Compiler,项目名称:qutebrowser,代码行数:34,代码来源:guiprocess.py

示例7: on_lists_downloaded

 def on_lists_downloaded(self):
     """Install block lists after files have been downloaded."""
     with open(self._local_hosts_file, 'w', encoding='utf-8') as f:
         for host in sorted(self._blocked_hosts):
             f.write(host + '\n')
         message.info("adblock: Read {} hosts from {} sources.".format(
             len(self._blocked_hosts), self._done_count))
开发者ID:Dietr1ch,项目名称:qutebrowser,代码行数:7,代码来源:adblock.py

示例8: spawn

    def spawn(self, win_id, userscript=False, quiet=False, *args):
        """Spawn a command in a shell.

        Note the {url} variable which gets replaced by the current URL might be
        useful here.

        //

        We use subprocess rather than Qt's QProcess here because we really
        don't care about the process anymore as soon as it's spawned.

        Args:
            userscript: Run the command as an userscript.
            quiet: Don't print the commandline being executed.
            *args: The commandline to execute.
        """
        log.procs.debug("Executing: {}, userscript={}".format(
            args, userscript))
        if not quiet:
            fake_cmdline = ' '.join(shlex.quote(arg) for arg in args)
            message.info(win_id, 'Executing: ' + fake_cmdline)
        if userscript:
            cmd = args[0]
            args = [] if not args else args[1:]
            self.run_userscript(cmd, *args)
        else:
            try:
                subprocess.Popen(args)
            except OSError as e:
                raise cmdexc.CommandError("Error while spawning command: "
                                          "{}".format(e))
开发者ID:andor44,项目名称:qutebrowser,代码行数:31,代码来源:commands.py

示例9: _handle_wheel

    def _handle_wheel(self, e):
        """Zoom on Ctrl-Mousewheel.

        Args:
            e: The QWheelEvent.
        """
        if self._ignore_wheel_event:
            # See https://github.com/qutebrowser/qutebrowser/issues/395
            self._ignore_wheel_event = False
            return True

        if e.modifiers() & Qt.ControlModifier:
            mode = modeman.instance(self._tab.win_id).mode
            if mode == usertypes.KeyMode.passthrough:
                return False

            divider = config.val.zoom.mouse_divider
            if divider == 0:
                return False
            factor = self._tab.zoom.factor() + (e.angleDelta().y() / divider)
            if factor < 0:
                return False
            perc = int(100 * factor)
            message.info("Zoom level: {}%".format(perc), replace=True)
            self._tab.zoom.set_factor(factor)
        elif e.modifiers() & Qt.ShiftModifier:
            if e.angleDelta().y() > 0:
                self._tab.scroller.left()
            else:
                self._tab.scroller.right()
            return True

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

示例10: message_info

def message_info(text):
    """Show an info message in the statusbar.

    Args:
        text: The text to show.
    """
    message.info(text)
开发者ID:lahwaacz,项目名称:qutebrowser,代码行数:7,代码来源:utilcmds.py

示例11: yank

    def yank(self, url, context):
        """Yank an element to the clipboard or primary selection.

        Args:
            url: The URL to open as a QUrl.
            context: The HintContext to use.
        """
        sel = (context.target == Target.yank_primary and
               utils.supports_selection())

        flags = QUrl.FullyEncoded | QUrl.RemovePassword
        if url.scheme() == 'mailto':
            flags |= QUrl.RemoveScheme
        urlstr = url.toString(flags)

        new_content = urlstr

        # only second and consecutive yanks are to append to the clipboard
        if context.rapid and not context.first_run:
            try:
                old_content = utils.get_clipboard(selection=sel)
            except utils.ClipboardEmptyError:
                pass
            else:
                new_content = os.linesep.join([old_content, new_content])
        utils.set_clipboard(new_content, selection=sel)

        msg = "Yanked URL to {}: {}".format(
            "primary selection" if sel else "clipboard",
            urlstr)
        message.info(msg)
开发者ID:The-Compiler,项目名称:qutebrowser,代码行数:31,代码来源:hints.py

示例12: set_command

    def set_command(self, win_id: {'special': 'win_id'},
                    sectname: {'name': 'section'}, optname: {'name': 'option'},
                    value=None, temp=False):
        """Set an option.

        If the option name ends with '?', the value of the option is shown
        instead.

        //

        Wrapper for self.set() to output exceptions in the status bar.

        Args:
            sectname: The section where the option is in.
            optname: The name of the option.
            value: The value to set.
            temp: Set value temporarily.
        """
        try:
            if optname.endswith('?'):
                val = self.get(sectname, optname[:-1], transformed=False)
                message.info(win_id, "{} {} = {}".format(
                    sectname, optname[:-1], val), immediately=True)
            else:
                if value is None:
                    raise cmdexc.CommandError("set: The following arguments "
                                              "are required: value")
                layer = 'temp' if temp else 'conf'
                self.set(layer, sectname, optname, value)
        except (NoOptionError, NoSectionError, configtypes.ValidationError,
                ValueError) as e:
            raise cmdexc.CommandError("set: {} - {}".format(
                e.__class__.__name__, e))
开发者ID:mfussenegger,项目名称:qutebrowser,代码行数:33,代码来源:config.py

示例13: set_command

    def set_command(self, win_id: {'special': 'win_id'},
                    sectname: {'name': 'section'}=None,
                    optname: {'name': 'option'}=None, value=None, temp=False,
                    print_val: {'name': 'print'}=False):
        """Set an option.

        If the option name ends with '?', the value of the option is shown
        instead.

        If the option name ends with '!' and it is a boolean value, toggle it.

        //

        Wrapper for self.set() to output exceptions in the status bar.

        Args:
            sectname: The section where the option is in.
            optname: The name of the option.
            value: The value to set.
            temp: Set value temporarily.
            print_val: Print the value after setting.
        """
        if sectname is not None and optname is None:
            raise cmdexc.CommandError(
                "set: Either both section and option have to be given, or "
                "neither!")
        if sectname is None and optname is None:
            tabbed_browser = objreg.get('tabbed-browser', scope='window',
                                        window=win_id)
            tabbed_browser.openurl(QUrl('qute:settings'), newtab=False)
            return

        if optname.endswith('?'):
            optname = optname[:-1]
            print_val = True
        else:
            try:
                if optname.endswith('!') and value is None:
                    val = self.get(sectname, optname[:-1])
                    layer = 'temp' if temp else 'conf'
                    if isinstance(val, bool):
                        self.set(layer, sectname, optname[:-1], str(not val))
                    else:
                        raise cmdexc.CommandError(
                            "set: Attempted inversion of non-boolean value.")
                elif value is not None:
                    layer = 'temp' if temp else 'conf'
                    self.set(layer, sectname, optname, value)
                else:
                    raise cmdexc.CommandError("set: The following arguments "
                                              "are required: value")
            except (configexc.Error, configparser.Error) as e:
                raise cmdexc.CommandError("set: {} - {}".format(
                    e.__class__.__name__, e))

        if print_val:
            val = self.get(sectname, optname, transformed=False)
            message.info(win_id, "{} {} = {}".format(
                sectname, optname, val), immediately=True)
开发者ID:JIVS,项目名称:qutebrowser,代码行数:59,代码来源:config.py

示例14: check_scroll_pos

 def check_scroll_pos():
     """Check if the scroll position got smaller and show info."""
     if not backward and self.scroll_pos < old_scroll_pos:
         message.info(self.win_id, "Search hit BOTTOM, continuing "
                      "at TOP", immediately=True)
     elif backward and self.scroll_pos > old_scroll_pos:
         message.info(self.win_id, "Search hit TOP, continuing at "
                      "BOTTOM", immediately=True)
开发者ID:AdaJass,项目名称:qutebrowser,代码行数:8,代码来源:webview.py

示例15: _write_backup

 def _write_backup(self, path):
     bak = path + '.bak'
     message.info('History import complete. Appending {} to {}'
                  .format(path, bak))
     with open(path, 'r', encoding='utf-8') as infile:
         with open(bak, 'a', encoding='utf-8') as outfile:
             for line in infile:
                 outfile.write('\n' + line)
     os.remove(path)
开发者ID:blyxxyz,项目名称:qutebrowser,代码行数:9,代码来源:history.py


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