import yaml
import logging


def open_config(config_path='config.yml'):
    """Opens YAML configuration file and returns a dict with config items. If path not
    given, defaults to config.yml on script file folder.

    Returns:
        dict: parsed YAML file with config items
    """
    try:
        with open(config_path, 'r') as fp:
            return yaml.load(fp, Loader=yaml.FullLoader)
    except OSError as e:
        logging.error("Error openning config file: %s" % e)
        exit(1)