def get_config_option(config, option, required=True):
    """
    Get an option (value of key) from provided config dictionary. If the key
    does not exist, exit with KeyError (required=True) or return None
    (required=False).
    """
    try:
        value = config[option]
        return value
    except KeyError:
        if required:
            raise KeyError(
                "Oops! I  couldn't find the required option in the "
                "config file. Check your config file to ensure the the {} "
                "option is populated".format(option)
            )
        else:
            return None