mirror of
https://github.com/RGBCube/GitHubWrapper
synced 2025-07-25 23:47:44 +00:00
Started the cache hopefully
This commit is contained in:
parent
fe977277be
commit
59001b7153
6 changed files with 253 additions and 0 deletions
49
Github/objetcts/repo.py
Normal file
49
Github/objetcts/repo.py
Normal file
|
@ -0,0 +1,49 @@
|
|||
#== repo.py ==#
|
||||
|
||||
import aiohttp
|
||||
|
||||
from .objects import APIOBJECT, dt_formatter
|
||||
from . import PartialUser
|
||||
from .. import http
|
||||
|
||||
__all__ = (
|
||||
'Repository',
|
||||
)
|
||||
|
||||
class Repository(APIOBJECT):
|
||||
__slots__ = (
|
||||
'id',
|
||||
'name',
|
||||
'owner',
|
||||
'size'
|
||||
'created_at',
|
||||
'url',
|
||||
'html_url',
|
||||
'archived',
|
||||
'disabled',
|
||||
'updated_at',
|
||||
'open_issues_count',
|
||||
'default_branch',
|
||||
'clone_url',
|
||||
'stargazers_count',
|
||||
'watchers_count',
|
||||
'forks',
|
||||
'license'
|
||||
)
|
||||
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 key.items():
|
||||
if key == 'owner':
|
||||
self.owner = PartialUser(value, self.session)
|
||||
return
|
||||
|
||||
if '_at' in key and value is not None:
|
||||
setattr(self, key, dt_formatter(value))
|
||||
return
|
||||
|
||||
setattr(self, key, value)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f'<Repository; id: {self.id}, name: {self.name}, owner: {self.owner}, created_at: {self.created_at}, default_branch: {self.default_branch}, license: {self.license}, >'
|
Loading…
Add table
Add a link
Reference in a new issue