Пример #1
0
def early_init(args: argparse.Namespace) -> None:
    """Initialize the part of the config which works without a QApplication."""
    configdata.init()

    yaml_config = configfiles.YamlConfig()

    config.instance = config.Config(yaml_config=yaml_config)
    config.val = config.ConfigContainer(config.instance)
    configapi.val = config.ConfigContainer(config.instance)
    config.key_instance = config.KeyConfig(config.instance)
    config.cache = configcache.ConfigCache()
    yaml_config.setParent(config.instance)

    for cf in config.change_filters:
        cf.validate()

    config_commands = configcommands.ConfigCommands(
        config.instance, config.key_instance)
    objreg.register('config-commands', config_commands, command_only=True)

    config_file = standarddir.config_py()
    custom_config_py = args.config_py is not None

    global _init_errors

    try:
        if os.path.exists(config_file) or custom_config_py:
            # If we have a custom --config-py flag, we want it to be fatal if it doesn't
            # exist, so we don't silently fall back to autoconfig.yml in that case.
            configfiles.read_config_py(
                config_file,
                warn_autoconfig=not custom_config_py,
            )
        else:
            configfiles.read_autoconfig()
    except configexc.ConfigFileErrors as e:
        log.config.error("Error while loading {}".format(e.basename))
        _init_errors = e

    try:
        configfiles.init()
    except configexc.ConfigFileErrors as e:
        _init_errors = e

    for opt, val in args.temp_settings:
        try:
            config.instance.set_str(opt, val)
        except configexc.Error as e:
            message.error("set: {} - {}".format(e.__class__.__name__, e))

    objects.backend = get_backend(args)
    objects.debug_flags = set(args.debug_flags)

    stylesheet.init()

    qtargs.init_envvars()
Пример #2
0
def early_init(args: argparse.Namespace) -> None:
    """Initialize the part of the config which works without a QApplication."""
    configdata.init()

    yaml_config = configfiles.YamlConfig()

    config.instance = config.Config(yaml_config=yaml_config)
    config.val = config.ConfigContainer(config.instance)
    configapi.val = config.ConfigContainer(config.instance)
    config.key_instance = config.KeyConfig(config.instance)
    config.cache = configcache.ConfigCache()
    yaml_config.setParent(config.instance)

    for cf in config.change_filters:
        cf.validate()

    config_commands = configcommands.ConfigCommands(config.instance,
                                                    config.key_instance)
    objreg.register('config-commands', config_commands, command_only=True)

    config_file = standarddir.config_py()
    global _init_errors

    try:
        if os.path.exists(config_file):
            configfiles.read_config_py(config_file)
        else:
            configfiles.read_autoconfig()
    except configexc.ConfigFileErrors as e:
        log.config.exception("Error while loading {}".format(e.basename))
        _init_errors = e

    try:
        configfiles.init()
    except configexc.ConfigFileErrors as e:
        _init_errors = e

    for opt, val in args.temp_settings:
        try:
            config.instance.set_str(opt, val)
        except configexc.Error as e:
            message.error("set: {} - {}".format(e.__class__.__name__, e))

    objects.backend = get_backend(args)
    objects.debug_flags = set(args.debug_flags)

    configtypes.Font.monospace_fonts = config.val.fonts.monospace
    config.instance.changed.connect(_update_monospace_fonts)

    stylesheet.init()

    _init_envvars()
Пример #3
0
def config_stub(stubs, monkeypatch, configdata_init, yaml_config_stub):
    """Fixture which provides a fake config object."""
    conf = config.Config(yaml_config=yaml_config_stub)
    monkeypatch.setattr(config, 'instance', conf)

    container = config.ConfigContainer(conf)
    monkeypatch.setattr(config, 'val', container)

    try:
        configtypes.Font.monospace_fonts = container.fonts.monospace
    except configexc.NoOptionError:
        # Completion tests patch configdata so fonts.monospace is unavailable.
        pass

    conf.val = container  # For easier use in tests
    return conf
Пример #4
0
def early_init(args):
    """Initialize the part of the config which works without a QApplication."""
    configdata.init()

    yaml_config = configfiles.YamlConfig()

    config.instance = config.Config(yaml_config=yaml_config)
    config.val = config.ConfigContainer(config.instance)
    config.key_instance = config.KeyConfig(config.instance)

    for cf in config.change_filters:
        cf.validate()

    configtypes.Font.monospace_fonts = config.val.fonts.monospace

    config_commands = config.ConfigCommands(config.instance,
                                            config.key_instance)
    objreg.register('config-commands', config_commands)

    config_api = None

    try:
        config_api = configfiles.read_config_py()
        # Raised here so we get the config_api back.
        if config_api.errors:
            raise configexc.ConfigFileErrors('config.py', config_api.errors)
    except configexc.ConfigFileErrors as e:
        log.config.exception("Error while loading config.py")
        _init_errors.append(e)

    try:
        if getattr(config_api, 'load_autoconfig', True):
            try:
                config.instance.read_yaml()
            except configexc.ConfigFileErrors as e:
                raise  # caught in outer block
            except configexc.Error as e:
                desc = configexc.ConfigErrorDesc("Error", e)
                raise configexc.ConfigFileErrors('autoconfig.yml', [desc])
    except configexc.ConfigFileErrors as e:
        log.config.exception("Error while loading config.py")
        _init_errors.append(e)

    configfiles.init()

    objects.backend = get_backend(args)
    earlyinit.init_with_backend(objects.backend)
Пример #5
0
def early_init(args):
    """Initialize the part of the config which works without a QApplication."""
    configdata.init()

    yaml_config = configfiles.YamlConfig()

    config.instance = config.Config(yaml_config=yaml_config)
    config.val = config.ConfigContainer(config.instance)
    config.key_instance = config.KeyConfig(config.instance)
    yaml_config.setParent(config.instance)

    for cf in config.change_filters:
        cf.validate()

    configtypes.Font.monospace_fonts = config.val.fonts.monospace

    config_commands = configcommands.ConfigCommands(config.instance,
                                                    config.key_instance)
    objreg.register('config-commands', config_commands)

    config_file = os.path.join(standarddir.config(), 'config.py')

    try:
        if os.path.exists(config_file):
            configfiles.read_config_py(config_file)
        else:
            configfiles.read_autoconfig()
    except configexc.ConfigFileErrors as e:
        log.config.exception("Error while loading {}".format(e.basename))
        global _init_errors
        _init_errors = e

    configfiles.init()

    objects.backend = get_backend(args)

    for opt, val in args.temp_settings:
        try:
            config.instance.set_str(opt, val)
        except configexc.Error as e:
            message.error("set: {} - {}".format(e.__class__.__name__, e))

    if (objects.backend == usertypes.Backend.QtWebEngine
            and config.val.force_software_rendering):
        os.environ['QT_XCB_FORCE_SOFTWARE_OPENGL'] = '1'
Пример #6
0
def config_stub(stubs, monkeypatch, configdata_init, yaml_config_stub, qapp):
    """Fixture which provides a fake config object."""
    conf = config.Config(yaml_config=yaml_config_stub)
    monkeypatch.setattr(config, 'instance', conf)

    container = config.ConfigContainer(conf)
    monkeypatch.setattr(config, 'val', container)
    monkeypatch.setattr(configapi, 'val', container)

    cache = configcache.ConfigCache()
    monkeypatch.setattr(config, 'cache', cache)

    try:
        configtypes.FontBase.set_defaults(None, '10pt')
    except configexc.NoOptionError:
        # Completion tests patch configdata so fonts.default_family is
        # unavailable.
        pass

    conf.val = container  # For easier use in tests

    stylesheet.init()

    return conf
Пример #7
0
 def conf(self, config_tmpdir):
     yaml_config = configfiles.YamlConfig()
     return config.Config(yaml_config)
Пример #8
0
 def conf(self, stubs):
     yaml_config = stubs.FakeYamlConfig()
     return config.Config(yaml_config)