import configparser


def get_config_default(key, default=None, setup_cfg_filename='setup.cfg'):
    """
    Get the default value for a configuration setting

    Parameters
    ==========
    key: str
        The key to read from the configuration

    default: str, optional
        A default value to return if the key is not present in the configuration.

    setup_cfg_filename: str
        The configuration file to parse for the configuration value.
    """
    config = configparser.ConfigParser()
    config.read(setup_cfg_filename)
    if 'screwdrivercd.version' in config.sections():
        return config['screwdrivercd.version'].get(key, default)

    if 'sdv4.version' in config.sections():
        return config['sdv4.version'].get(key, default)

    if 'ouroath.platform_version' in config.sections():  # pragma: no cover
        return config['ouroath.platform_version'].get(key, default)

    return default