import yaml


def get_target_directory_from_config_file(cfg_src):
    """
    Gets download directory from specified section in
    a configuration file.
    """
    # reading complete configuration
    with open(cfg_src, 'r') as yml_file:
        cfg = yaml.safe_load(yml_file)

    try:
        tgt_dir = cfg['downloading']['tgt_dir']
    except KeyError as e:
        print(
            "Unable to retrieve parameter '%s' "
            "from configuration file." % e.args[0])
        return
    except Exception:
        print("Unable to read configuration file")
        return

    return tgt_dir