1
Fork 0
mirror of https://github.com/RGBCube/GitHubWrapper synced 2025-05-18 15:05:08 +00:00

Added a few more methods to the main entry point

This commit is contained in:
sudosnok 2022-03-27 11:08:28 +01:00
parent 24d539a789
commit 3fb907f6ef

View file

@ -26,10 +26,28 @@ class Github:
auth_token = getpass.getpass('Enter your token: ')
self._auth = aiohttp.BasicAuth(username, auth_token)
async def start(self):
def __repr__(self) -> str:
return f'<Github Client; has_auth={bool(self._auth)}>'
def update_auth(self) -> None:
"""Allows you to input auth information after instantiating the client."""
username = input('Enter your username: ')
token = getpass('Enter your token: ')
self._auth = aiohttp.BasicAuth(username, token)
async def start(self) -> None:
"""Main entry point to the wrapper, this creates the ClientSession."""
self.session = await http.make_session(headers=self._headers, authorization=self._auth)
async def get_user(self, username: str):
async def get_user(self, username: str) -> User:
"""Fetch a Github user from their username."""
return User(await http.get_user(self.session, username), self.session)
async def get_repo(self, repo_name: str) -> 'Repo':
"""Fetch a Github repository from it's name."""
pass
async def get_org(self, org_name: str) -> 'Org':
"""Fetch a Github organization from it's name"""
pass