def generate_readme(project, repo=None, version=None):
    """Generates a readme for the Python package, based on the readme file

    Args:
        project (str):
            name of the project to generate the readme for
        repo (str):
            optional name of the git repo for the project
            if not provided, it is assumed the repo name matches the project
            name
        version (str):
            optional version of the package being generated
            when not provided, will default to "latest"

    Returns:
        str: readme text for the package
    """
    if repo is None:
        repo = project

    if not version or "dev" in version:
        branch = "branch=master"
        version = "latest"

    else:
        branch = "tag=" + version

    headers = list()
    headers.append({
        "image":
            "https://travis-ci.org/TheFriendlyCoder/{0}.svg?{1}".
            format(repo, branch),
        "target":
            "https://travis-ci.org/TheFriendlyCoder/{0}".
            format(repo),
        "text": "Build Automation"
    })
    headers.append({
        "image": "https://coveralls.io/repos/github/TheFriendlyCoder/{0}/"
                 "badge.svg?{1}".format(repo, branch),
        "target":
            "https://coveralls.io/github/TheFriendlyCoder/{0}?{1}".
            format(repo, branch),
        "text": "Test Coverage"
    })
    headers.append({
        "image":
            "https://img.shields.io/pypi/pyversions/{0}.svg".
            format(project),
        "target": "https://pypi.python.org/pypi/{0}".format(project),
        "text": "Python Versions"
    })
    headers.append({
        "image":
            "https://readthedocs.org/projects/{0}/badge/?version={1}".
            format(project, version),
        "target": "http://{0}.readthedocs.io/en/{1}".format(project, version),
        "text": "Documentation Status"
    })
    headers.append({
        "image":
            "https://requires.io/github/TheFriendlyCoder/{0}/"
            "requirements.svg?{1}".format(repo, branch),
        "target":
            "https://requires.io/github/TheFriendlyCoder/{0}/"
            "requirements/?{1}".format(repo, branch),
        "text": "Requirements Status"
    })
    headers.append({
        "image": "https://img.shields.io/pypi/format/{0}.svg".format(project),
        "target": "https://pypi.python.org/pypi/{0}/".format(project),
        "text": "Package Format"
    })
    headers.append({
        "image": "https://img.shields.io/pypi/dm/{0}.svg".format(project),
        "target": "https://pypi.python.org/pypi/{0}/".format(project),
        "text": "Download Count"
    })
    headers.append({
        "image": "https://img.shields.io/pypi/l/{0}.svg".format(project),
        "target": "https://www.apache.org/licenses/LICENSE-2.0.txt",
        "text": "Apache License 2.0"
    })

    header_template = """.. image:: {0}
    :target: {1}
    :alt: {2}

    """

    retval = ""
    for cur_header in headers:
        retval += header_template.format(
            cur_header["image"], cur_header["target"], cur_header["text"])
        retval += "\n"

    with open('README.rst') as readme:
        retval += readme.read()

    return retval