def pkg_url(cfg):
    """Extract a valid url from all config sections.

    Args:
        cfg (Config):  current package configuration

    Returns:
        (str): a valid url for the package
    """
    try:
        url = cfg['base']['url']
        if url is not None:
            return url
    except KeyError:
        pass
    try:
        url = cfg['github']['url']
        if url is not None:
            return url
    except KeyError:
        pass
    try:
        url = cfg['gitlab']['url']
        if url is not None:
            return url
    except KeyError:
        pass
    return ''
