Esempio n. 1
0
 def __init__(self, parent=None):
     super().__init__(parent)
     datadir = standarddir.get(QStandardPaths.DataLocation)
     self._linecp = lineparser.LineConfigParser(datadir, 'cookies',
                                                binary=True)
     cookies = []
     for line in self._linecp:
         cookies += QNetworkCookie.parseCookies(line)
     self.setAllCookies(cookies)
     objreg.get('config').changed.connect(self.cookies_store_changed)
Esempio n. 2
0
def init(args):
    """Initialize the config.

    Args:
        args: The argparse namespace.
    """
    confdir = standarddir.get(QStandardPaths.ConfigLocation, args)
    try:
        app = objreg.get('app')
        config_obj = ConfigManager(confdir, 'qutebrowser.conf', app)
    except (configtypes.ValidationError, NoOptionError, NoSectionError,
            UnknownSectionError, InterpolationSyntaxError,
            configparser.InterpolationError,
            configparser.DuplicateSectionError,
            configparser.DuplicateOptionError, configparser.ParsingError) as e:
        log.init.exception(e)
        errstr = "Error while reading config:"
        if hasattr(e, 'section') and hasattr(e, 'option'):
            errstr += "\n\n{} -> {}:".format(e.section, e.option)
        errstr += "\n{}".format(e)
        msgbox = QMessageBox(QMessageBox.Critical,
                             "Error while reading config!", errstr)
        msgbox.exec_()
        # We didn't really initialize much so far, so we just quit hard.
        sys.exit(1)
    else:
        objreg.register('config', config_obj)
    try:
        key_config = keyconfparser.KeyConfigParser(confdir, 'keys.conf')
    except keyconfparser.KeyConfigError as e:
        log.init.exception(e)
        errstr = "Error while reading key config:\n"
        if e.lineno is not None:
            errstr += "In line {}: ".format(e.lineno)
        errstr += str(e)
        msgbox = QMessageBox(QMessageBox.Critical,
                             "Error while reading key config!", errstr)
        msgbox.exec_()
        # We didn't really initialize much so far, so we just quit hard.
        sys.exit(1)
    else:
        objreg.register('key-config', key_config)

    datadir = standarddir.get(QStandardPaths.DataLocation, args)
    state_config = iniparsers.ReadWriteConfigParser(datadir, 'state')
    objreg.register('state-config', state_config)
    # We need to import this here because lineparser needs config.
    from qutebrowser.config import lineparser
    command_history = lineparser.LineConfigParser(
        datadir, 'cmd-history', ('completion', 'history-length'))
    objreg.register('command-history', command_history)
Esempio n. 3
0
    def __init__(self, parent=None):
        """Initialize and read quickmarks."""
        super().__init__(parent)

        self.marks = collections.OrderedDict()

        confdir = standarddir.get(QStandardPaths.ConfigLocation)
        self._linecp = lineparser.LineConfigParser(confdir, 'quickmarks')
        for line in self._linecp:
            try:
                key, url = line.rsplit(maxsplit=1)
            except ValueError:
                message.error(0, "Invalid quickmark '{}'".format(line))
            else:
                self.marks[key] = url