How to use the peeringdb.config.default_config function in peeringdb

To help you get started, we’ve selected a few peeringdb 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 peeringdb / peeringdb-py / tests / test_config.py View on Github external
def test_write():
    with TemporaryDirectory() as td:
        DEFAULT = config.default_config()
        config.write_config(DEFAULT, td)
github peeringdb / peeringdb-py / tests / test_config.py View on Github external
def test_load_config(config0_dir):
    with pytest.raises(IOError):
        config.load_config('nonexistent')

    c = config.load_config(config0_dir)
    DEFAULT = config.default_config()
    assert c['sync'] != DEFAULT['sync']
    assert c['sync']['timeout'] == 60
    assert c['sync']['strip_tz'] == DEFAULT['sync']['strip_tz']
    assert c['sync']['url'] != DEFAULT['sync']['url']
github peeringdb / peeringdb-py / peeringdb / cli.py View on Github external
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