-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGithubRepoLister.py
57 lines (39 loc) · 1.13 KB
/
GithubRepoLister.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import requests
from os import system, name
def clear_screen():
"""
Clears the screen.
"""
if name == "nt":
system("cls")
else:
system("clear")
clear_screen()
def fetch_repos(username, page=1):
"""
Fetches a list of repositories for a given user.
Args:
username (str): The username of the user to fetch repositories for.
page (int, optional): The page number to fetch. Defaults to 1.
Returns:
list[dict]: A list of dictionaries containing the repository data.
"""
url = f"https://api.github.com/users/{username}/repos"
params = {"page": page}
return requests.get(url, params=params).json()
def main():
username = input("Enter your GitHub username ~> ")
page_num = 1
while True:
repos = fetch_repos(username, page_num)
if not repos:
break
for repo in repos:
print(f" ~ {repo['full_name']}: {repo['description']} \n")
prompt = input("Next? [y/N] ~> ")
if prompt.lower() != "y":
break
page_num += 1
print("Goodbye!")
if __name__ == "__main__":
main()