def get_java_files()

in crashclouseau/java.py [0:0]


def get_java_files(root, sha, sleep=0.1, retry=10):
    url = "{}/git/trees/{}?recursive=1".format(GITHUB_URL, sha)
    for _ in range(retry):
        r = requests.get(url)
        if r.status_code == 200:
            res = []
            for data in r.json()["tree"]:
                path = data["path"]
                if path.endswith(".java"):
                    res.append(root + "/" + path)
            return res
        else:
            time.sleep(sleep)
    raise Exception("Too many attempts in java.get_java_files (retry={})".format(retry))