mirror of
https://github.com/RGBCube/GitHubWrapper
synced 2025-05-18 23:15:09 +00:00
Adding Objects
This commit is contained in:
parent
633f8d0183
commit
beaf181a52
1 changed files with 61 additions and 0 deletions
61
Github/objects.py
Normal file
61
Github/objects.py
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
#== objects.py ==#
|
||||||
|
|
||||||
|
from collections import namedtuple
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
import aiohttp
|
||||||
|
|
||||||
|
from . import http
|
||||||
|
|
||||||
|
__all__ = (
|
||||||
|
'User',
|
||||||
|
)
|
||||||
|
|
||||||
|
class APIOBJECT():
|
||||||
|
__slots__ = (
|
||||||
|
'response',
|
||||||
|
)
|
||||||
|
|
||||||
|
def __init__(self, response: dict, session: aiohttp.ClientSession) -> None:
|
||||||
|
self.response = response
|
||||||
|
self.state = session
|
||||||
|
|
||||||
|
|
||||||
|
def __repr__(self) -> str:
|
||||||
|
return f'<{self.__class__.__name__}>'
|
||||||
|
|
||||||
|
class _BaseUser(APIOBJECT):
|
||||||
|
__slots__ = (
|
||||||
|
'reponse',
|
||||||
|
'name',
|
||||||
|
'id',
|
||||||
|
)
|
||||||
|
def __init__(self, response: dict, session: aiohttp.ClientSession) -> None:
|
||||||
|
super().__init__(response, session=session)
|
||||||
|
self.login = response.get('login')
|
||||||
|
self.id = response.get('id')
|
||||||
|
|
||||||
|
def __repr__(self) -> str:
|
||||||
|
return f'<{self.__class__.__name__}; id = {self.id}, login = {self.login}>'
|
||||||
|
|
||||||
|
class User(_BaseUser):
|
||||||
|
__slots__ = (
|
||||||
|
'login',
|
||||||
|
'id',
|
||||||
|
'avatar_url',
|
||||||
|
'html_url',
|
||||||
|
'public_repos',
|
||||||
|
'public_gists',
|
||||||
|
'followers',
|
||||||
|
'following'
|
||||||
|
'created_at',
|
||||||
|
)
|
||||||
|
def __init__(self, response: dict, session: aiohttp.ClientSession) -> None:
|
||||||
|
super().__init__(response, session)
|
||||||
|
...
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue