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()
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()
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)
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'
def key_config_stub(config_stub, monkeypatch): """Fixture which provides a fake key config object.""" keyconf = config.KeyConfig(config_stub) monkeypatch.setattr(config, 'key_instance', keyconf) return keyconf
def keyconf(self, config_stub): config_stub.val.aliases = {} return config.KeyConfig(config_stub)