コード例 #1
0
ファイル: commands.py プロジェクト: Temikus/esque
def config_migrate(state: State):
    """Migrate esque config to current version.

    If the user's esque config file is from a previous version, migrate it to the current version.
    A backup of the original config file is created with the same name and the extension .bak"""
    new_path, backup = migration.migrate(config_path())
    click.echo(f"Your config has been migrated and is now at {new_path}. A backup has been created at {backup}.")
コード例 #2
0
def test_backup(config_version: int, load_config: config_loader):
    old_conf, old_yaml = load_config(config_version)
    _, backup = migrate(Path(old_conf))
    if config_version == CURRENT_VERSION:
        assert backup is None, "No need for backup"
        return

    assert backup.read_text() == old_yaml
コード例 #3
0
ファイル: test_config.py プロジェクト: real-digital/esque
 def migration_wrapper(config_path: Path):
     nonlocal new_conf_path, backup
     new_conf_path, backup = migrate(config_path)
     return new_conf_path, backup
コード例 #4
0
def test_schema(config_version: int, load_config: config_loader):
    old_conf, _ = load_config(config_version)
    new_path, _ = migrate(Path(old_conf))

    validate_esque_config(yaml.safe_load(new_path.read_text()))
コード例 #5
0
def config(config_version: int, load_config: config_loader):
    old_conf, _ = load_config(config_version)
    new_path, _ = migrate(Path(old_conf))
    Config.set_instance(Config())
    return Config.get_instance()