mirror of
https://github.com/RGBCube/GitHubWrapper
synced 2025-05-18 15:05:08 +00:00
adding gists
This commit is contained in:
parent
b297e81bd0
commit
63fb8021ce
1 changed files with 41 additions and 0 deletions
41
Github/objects/gists.py
Normal file
41
Github/objects/gists.py
Normal file
|
@ -0,0 +1,41 @@
|
|||
#== gists.py ==#
|
||||
|
||||
import aiohttp
|
||||
|
||||
from .objects import APIOBJECT, dt_formatter
|
||||
from . import PartialUser, User
|
||||
from .. import http
|
||||
|
||||
__all__ = (
|
||||
'Gist',
|
||||
)
|
||||
|
||||
class Gist(APIOBJECT):
|
||||
__slots__ = (
|
||||
'id',
|
||||
'description',
|
||||
'html_url',
|
||||
'node_id',
|
||||
'files',
|
||||
'public',
|
||||
'owner',
|
||||
'created_at',
|
||||
'comments',
|
||||
'truncated',
|
||||
)
|
||||
def __init__(self, response: dict, session: aiohttp.ClientSession) -> None:
|
||||
super().__init__(response, session)
|
||||
tmp = self.__slots__ + APIOBJECT.__slots__
|
||||
keys = {key: value for key,value in self._response.items() if key in tmp}
|
||||
for key, value in keys.items():
|
||||
if key == 'owner':
|
||||
setattr(self, key, PartialUser(value, session))
|
||||
continue
|
||||
if key == 'created_at':
|
||||
setattr(self, key, dt_formatter(value))
|
||||
continue
|
||||
else:
|
||||
setattr(self, key, value)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f'<Gist; id: {self.id}, owner: {self.owner}, created_at: {self.created_at}>'
|
Loading…
Add table
Add a link
Reference in a new issue