import json


def get_top_python_packages(top_n=100):
    """
    Generate list of most downloaded python packages

    Args:
        top_n: the number of most downloaded packages to return

    Returns:
        (list) Names of most downloaded packages
    """
    # JSON file containing top 4000 packages
    # found here: https://hugovk.github.io/top-pypi-packages/
    top_python_pkgs = "top_python_pkg_downloads.json"
    with open(top_python_pkgs, "r") as j:
        contents = json.loads(j.read())

        # store names of top packges
        top_pkgs = []
        cnt = 0
        for pkg in contents["rows"]:
            # only append TOP_N number of packages
            if cnt == top_n:
                break
            top_pkgs.append(pkg["project"])
            cnt += 1

        return top_pkgs