def iter_version_links(html, name):
    """
    Iterate through version links (in order) within HTML.

    Filtering out links that don't "look" like versions.

    Either yields hrefs to be recursively searches or tuples of (name, href)
    that match the given name.
    """
    soup = BeautifulSoup(html)
    for node in soup.findAll("a"):
        if node.get("href") is None:
            continue
        try:
            guessed_name, _ = guess_name_and_version(node.text)
        except __HOLE__:
            href = node["href"]
            for extension in [".tar.gz", ".zip"]:
                if href.endswith(extension):
                    yield basename(href), href
                    break
            else:
                if node.get("rel") == "download":
                    # Might be a recursive link.
                    yield href
            # else couldn't parse name and version, probably the wrong kind of link
        else:
            if guessed_name.replace("_", "-").lower() != name.replace("_", "-").lower():
                continue
            yield node.text, node["href"]
dataset/ETHPy150Open jessemyers/cheddar/cheddar/index/remote.py/iter_version_links