-
Notifications
You must be signed in to change notification settings - Fork 0
/
urepos_active_rest.py
56 lines (43 loc) · 1.65 KB
/
urepos_active_rest.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
"""Quickly identify repos that are active and inactive from a user's personal...
repos, starred and watching
Note that this is the REST version and is less optimised than the Graph version
This has been kept so a comparison can be made
"""
from __future__ import annotations
from typing import Any
from lib import github_rest
from lib.metprint import LogType
from lib.utils import getUsernameAndLifespan, printf
def forEachRepo(sourceRepo: dict[str, Any]) -> None:
"""Is source repo alive?."""
printStr = ["dead", LogType.ERROR]
if github_rest.sourceAlive(sourceRepo, death):
printStr = ["alive", LogType.SUCCESS]
printf.logPrint(f"Source repo is {printStr[0]}! Head to {sourceRepo['html_url']}", printStr[1])
"""Get list of forked repos that are alive and newer than the source repo
"""
aliveRepos, forkedRepos = github_rest.getListOfAliveForks(repo, death)
printf.logPrint(
f"{len(aliveRepos)} out of {len(forkedRepos)} Forked repos are "
"alive and newer than the source!",
LogType.BOLD,
)
for aliveRepo in aliveRepos:
github_rest.printRepo(aliveRepo)
username, death = getUsernameAndLifespan()
choice = input("User repos, watched or starred (R/w/s)>")
if choice.lower() == "s":
"""Get list of user starred"""
starredRepos = github_rest.getListOfUserRepos(username, "starred")
for repo in starredRepos:
forEachRepo(repo)
elif choice.lower() == "w":
"""Get list of user watched"""
watchedRepos = github_rest.getListOfUserRepos(username, "subscriptions")
for repo in watchedRepos:
forEachRepo(repo)
else:
"""Get list of user repos"""
sourceRepos = github_rest.getListOfUserRepos(username, "repos")
for repo in sourceRepos:
forEachRepo(repo)