How to use the instawow.config.Config function in instawow

To help you get started, we’ve selected a few instawow examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github layday / instawow / tests / test_config.py View on Github external
def test_invalid_any_dir_raises(full_config, dir_):
    with pytest.raises(ValueError):  # type: ignore
        Config(**{**full_config, dir_: '~foo'})
github layday / instawow / tests / test_config.py View on Github external
def test_default_config_dir_is_platform_and_xdg_appropriate(partial_config, monkeypatch):
    with monkeypatch.context() as patcher:
        patcher.setattr(sys, 'platform', 'linux')
        config_dir = Config(**partial_config).config_dir
        assert config_dir == Path.home() / '.config/instawow'

        patcher.setenv('XDG_CONFIG_HOME', '/foo')
        config_dir = Config(**partial_config).config_dir
        assert config_dir == Path('/foo/instawow')

    with monkeypatch.context() as patcher:
        patcher.setattr(sys, 'platform', 'darwin')
        config_dir = Config(**partial_config).config_dir
        assert config_dir == Path.home() / 'Library/Application Support/instawow'
github layday / instawow / tests / test_config.py View on Github external
def test_config_dir_is_populated(full_config):
    config = Config(**full_config).write()
    assert {i.name for i in config.config_dir.iterdir()} == {'config.json', 'logs', 'plugins'}
github layday / instawow / tests / test_ws_api.py View on Github external
def config(tmp_path_factory):
    config = Config(config_dir=tmp_path_factory.mktemp(f'{__name__}_config'),
                    addon_dir=tmp_path_factory.mktemp(f'{__name__}_addons'))
    config.write()
    yield config
github layday / instawow / tests / test_config.py View on Github external
def test_default_config_dir_on_win32(partial_config, monkeypatch):
    assert Config(**partial_config).config_dir == Path.home() / 'AppData/Roaming/instawow'
    monkeypatch.delenv('APPDATA')
    assert Config(**partial_config).config_dir == Path.home() / 'instawow'
github layday / instawow / tests / test_config.py View on Github external
def test_reading_config_file(full_config, profile):
    Config(**full_config, profile=profile).write()
    config_json = {
        'addon_dir': str(full_config['addon_dir']),
        'game_flavour': full_config['game_flavour'],
        'profile': profile,
    }
    config_loc = full_config['config_dir']
    if profile:
        config_loc = config_loc / 'profiles' / profile
    assert config_json == json.loads((config_loc / 'config.json').read_text())
github layday / instawow / tests / test_config.py View on Github external
def test_invalid_addon_dir_raises(full_config):
    with pytest.raises(ValueError, match='must be a writable directory'):  # type: ignore
        Config(**{**full_config, 'addon_dir': 'foo'})
github layday / instawow / tests / test_config.py View on Github external
def test_env_vars_have_prio(full_config, monkeypatch):
    monkeypatch.setenv('INSTAWOW_CONFIG_DIR', '/foo')
    monkeypatch.setenv('INSTAWOW_GAME_FLAVOUR', 'classic')

    config = Config(**full_config)
    assert config.config_dir == Path('/foo').resolve()
    assert config.game_flavour == 'classic'
github layday / instawow / instawow / cli.py View on Github external
def m(self) -> CliManager:
        import asyncio

        from .config import Config
        from .manager import CliManager, prepare_db_session

        # TODO: remove once https://github.com/aio-libs/aiohttp/issues/4324 is fixed
        policy = getattr(asyncio, 'WindowsSelectorEventLoopPolicy', None)
        if policy:
            asyncio.set_event_loop_policy(policy())

        while True:
            try:
                config = Config.read(profile=self.ctx.params['profile']).ensure_dirs()
            except FileNotFoundError:
                self.ctx.invoke(configure)
            else:
                break

        setup_logging(config.logger_dir, 'DEBUG' if self.ctx.params['debug'] else 'INFO')
        db_session = prepare_db_session(config)
        manager = CliManager(config, db_session)
        return manager
github layday / instawow / instawow / api.py View on Github external
async def setup() -> Config:
            config = Config(**dict(self.params)).write()
            setup_logging(config)
            manager.finalise(config)
            return config