Exemplo n.º 1
0
 def handle(config, defaults, config_dir, output_format, **_):
     if defaults:
         newconfig = config
         outdir = config_dir
     else:
         newconfig = cfg.prompt_config(cfg.CLIENT_SCHEMA, defaults=config)
         outdir = util.prompt("Output directory", config_dir)
     cfg.write_config(newconfig, outdir, codec=output_format)
Exemplo n.º 2
0
def check_load_config(config_dir):
    convert = False
    loaded = config.read_config(config_dir) or {}

    if config.detect_old(loaded):
        print(
            "Found config file with pre-0.7 schema; backing up and converting to new format"
        )
        convert = True
        cfg = config.convert_old(loaded)
    else:
        cfg = config.default_config()
        config.recursive_update(cfg, loaded)

    if convert:
        config.write_config(cfg, config_dir, backup_existing=True)
    return cfg
Exemplo n.º 3
0
def test_write():
    with TemporaryDirectory() as td:
        DEFAULT = config.default_config()
        config.write_config(DEFAULT, td)