def generate_settings(filename): """Generate the complete settings section.""" configdata.init() with _open_file(filename) as f: f.write(FILE_HEADER) f.write("= Setting reference\n\n") f.write("== All settings\n") f.write(_get_setting_quickref() + "\n") for opt in sorted(configdata.DATA.values()): _generate_setting_option(f, opt) f.write("\n== Setting types\n") f.write(_get_setting_types_quickref() + "\n")
def test_dicts(): """Test available dictionaries.""" configdata.init() for lang in dictcli.available_languages(): print('Testing dictionary {}... '.format(lang.code), end='') lang_url = urllib.parse.urljoin(dictcli.API_URL, lang.remote_path) request = urllib.request.Request(lang_url, method='HEAD') response = urllib.request.urlopen(request) if response.status == 200: print('OK') else: print('ERROR: {}'.format(response.status))
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) config_file = standarddir.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() 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) configtypes.Font.monospace_fonts = config.val.fonts.monospace config.instance.changed.connect(_update_monospace_fonts) _init_envvars()
def main(): """Check by which hostblock list a host was blocked.""" if len(sys.argv) != 2: print("Usage: {} <host>".format(sys.argv[0]), file=sys.stderr) sys.exit(1) configdata.init() for url in configdata.DATA['content.host_blocking.lists'].default: print("checking {}...".format(url)) raw_file = urllib.request.urlopen(url) byte_io = io.BytesIO(raw_file.read()) f = adblock.get_fileobj(byte_io) for line in f: line = line.decode('utf-8') if sys.argv[1] in line: print("FOUND {} in {}:".format(sys.argv[1], url)) print(" " + line.rstrip())
def main(): check_root() if configdata.DATA is None: configdata.init() standarddir.init(None) parser = get_argparser() argv = sys.argv[1:] args = parser.parse_args(argv) languages = available_languages() if args.cmd == 'list': print_list(languages) elif args.cmd == 'update': update(languages) elif args.cmd == 'remove-old': remove_old(languages) elif not args.language: sys.exit('You must provide a list of languages to install.') else: try: install(filter_languages(languages, args.language)) except InvalidLanguageError as e: print(e)
def configdata_init(monkeypatch): """Make sure configdata is init'ed and no test re-init's it.""" if not configdata.DATA: configdata.init() monkeypatch.setattr(configdata, 'init', lambda: None)
def configdata_init(): if configdata.DATA is None: configdata.init()
def configdata_init(): """Initialize configdata if needed.""" if configdata.DATA is None: configdata.init()