Delete a repo from ``/etc/opkg/*.conf``

    If the file does not contain any other repo configuration, the file itself
    will be deleted.

    CLI Examples:

    .. code-block:: bash

        salt '*' pkg.del_repo repo

def del_repo(repo, **kwargs):  # pylint: disable=unused-argument
    '''
    Delete a repo from ``/etc/opkg/*.conf``

    If the file does not contain any other repo configuration, the file itself
    will be deleted.

    CLI Examples:

    .. code-block:: bash

        salt '*' pkg.del_repo repo
    '''
    refresh = salt.utils.data.is_true(kwargs.get('refresh', True))
    repos = list_repos()
    if repos:
        deleted_from = dict()
        for repository in repos:
            source = repos[repository][0]
            if source['name'] == repo:
                deleted_from[source['file']] = 0
                _del_repo_from_file(repo, source['file'])

        if deleted_from:
            ret = ''
            for repository in repos:
                source = repos[repository][0]
                if source['file'] in deleted_from:
                    deleted_from[source['file']] += 1
            for repo_file, count in six.iteritems(deleted_from):
                msg = 'Repo \'{0}\' has been removed from {1}.\n'
                if count == 1 and os.path.isfile(repo_file):
                    msg = ('File {1} containing repo \'{0}\' has been '
                           'removed.\n')
                    try:
                        os.remove(repo_file)
                    except OSError:
                        pass
                ret += msg.format(repo, repo_file)
            if refresh:
                refresh_db()
            return ret

    return "Repo {0} doesn't exist in the opkg repo lists".format(repo)