Spaces:
Runtime error
Runtime error
File size: 641 Bytes
a908fc5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
"""This file deals with every detail of how to get all python files in the given directory
"""
import requests
def get_repository_python_files(owner: str, repo: str, path: str = "", ref: str = ""):
"""https://docs.github.com/en/rest/repos/contents#get-repository-content"""
api_url = f"https://api.github.com/repos/{owner}/{repo}/contents/{path}"
if ref:
api_url += f"?ref={ref}"
python_files = []
api_results = requests.get(api_url).json()
for result in api_results:
if result["type"] == "file" and result["name"].endswith(".py"):
python_files.append(result)
return python_files
|