2021-11-04 05:01:35 +00:00
|
|
|
from rich.table import Table
|
|
|
|
from rich.prompt import Prompt
|
|
|
|
from rich import print
|
|
|
|
from api import API
|
2021-11-05 01:48:38 +00:00
|
|
|
import httpx
|
2021-11-04 05:01:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
class GHub:
|
|
|
|
user = None
|
|
|
|
repos = None
|
|
|
|
|
2021-11-05 03:30:12 +00:00
|
|
|
def load_user(self, user_name: str)-> None:
|
2021-11-04 05:01:35 +00:00
|
|
|
self.user_name = user_name
|
2021-11-05 01:48:38 +00:00
|
|
|
self.api = API()
|
2021-11-05 03:30:12 +00:00
|
|
|
self.user = self.api.get(f"/users/{user_name}")
|
|
|
|
self.repos = self.api.get_with_pagination(
|
|
|
|
f"https://api.github.com/users/{user_name}/repos"
|
|
|
|
)
|
2021-11-04 05:01:35 +00:00
|
|
|
|
|
|
|
def repos_trimmed(self) -> list:
|
|
|
|
for repo in self.repos:
|
|
|
|
yield [
|
|
|
|
str(f)
|
|
|
|
for f in [
|
|
|
|
repo["name"],
|
|
|
|
repo["description"],
|
|
|
|
repo["stargazers_count"],
|
|
|
|
repo["watchers_count"],
|
|
|
|
repo["forks_count"],
|
|
|
|
repo["open_issues_count"],
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
def repos_table(self) -> Table:
|
|
|
|
table = Table(show_header=True, header_style="bold magenta")
|
|
|
|
table.add_column("Name")
|
|
|
|
table.add_column("Description")
|
|
|
|
table.add_column("Stargazers")
|
|
|
|
table.add_column("Watchers")
|
|
|
|
table.add_column("Forks")
|
|
|
|
table.add_column("Open Issues")
|
|
|
|
for repo in self.repos_trimmed():
|
|
|
|
table.add_row(*repo)
|
|
|
|
return table
|