mirror of
https://github.com/RGBCube/GitHubWrapper
synced 2025-05-18 06:55:09 +00:00
add properties
This commit is contained in:
parent
cc44cb67e5
commit
a3aa1a51a8
2 changed files with 50 additions and 7 deletions
|
@ -261,6 +261,7 @@ class http:
|
||||||
data['files'] = {}
|
data['files'] = {}
|
||||||
for file in files:
|
for file in files:
|
||||||
data['files'][file.filename] = {
|
data['files'][file.filename] = {
|
||||||
|
'filename' : file.filename, # helps editing the file
|
||||||
'content': file.read()
|
'content': file.read()
|
||||||
}
|
}
|
||||||
data = json.dumps(data)
|
data = json.dumps(data)
|
||||||
|
@ -285,4 +286,3 @@ class http:
|
||||||
if result.status == 401:
|
if result.status == 401:
|
||||||
raise NoAuthProvided
|
raise NoAuthProvided
|
||||||
raise RepositoryAlreadyExists
|
raise RepositoryAlreadyExists
|
||||||
|
|
||||||
|
|
|
@ -144,7 +144,6 @@ class Repository(APIObject):
|
||||||
'clone_url',
|
'clone_url',
|
||||||
'stargazers_count',
|
'stargazers_count',
|
||||||
'watchers_count',
|
'watchers_count',
|
||||||
'forks',
|
|
||||||
'license',
|
'license',
|
||||||
)
|
)
|
||||||
def __init__(self, response: dict, _http: http) -> None:
|
def __init__(self, response: dict, _http: http) -> None:
|
||||||
|
@ -177,6 +176,22 @@ class Repository(APIObject):
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
return f'<{self.__class__.__name__}; id: {self.id}, name: {self.name!r}, owner: {self.owner!r}>'
|
return f'<{self.__class__.__name__}; id: {self.id}, name: {self.name!r}, owner: {self.owner!r}>'
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_fork(self) -> bool:
|
||||||
|
return self._response.get('fork')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def language(self) -> str:
|
||||||
|
return self._response.get('language')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def open_issues(self) -> int:
|
||||||
|
return self._response.get('open_issues')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def forks(self) -> int:
|
||||||
|
return self._response.get('forks')
|
||||||
|
|
||||||
class Issue(APIObject):
|
class Issue(APIObject):
|
||||||
__slots__ = (
|
__slots__ = (
|
||||||
'id',
|
'id',
|
||||||
|
@ -212,6 +227,13 @@ class Issue(APIObject):
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
return f'<{self.__class__.__name__}; id: {self.id}, title: {self.title}, user: {self.user}, created_at: {self.created_at}, state: {self.state}>'
|
return f'<{self.__class__.__name__}; id: {self.id}, title: {self.title}, user: {self.user}, created_at: {self.created_at}, state: {self.state}>'
|
||||||
|
|
||||||
|
@property
|
||||||
|
def updated_at(self) -> str:
|
||||||
|
return dt_formatter(self._response.get('updated_at'))
|
||||||
|
|
||||||
|
@property
|
||||||
|
def html_url(self) -> str:
|
||||||
|
return self._response.get('html_url')
|
||||||
|
|
||||||
#=== Gist stuff ===#
|
#=== Gist stuff ===#
|
||||||
|
|
||||||
|
@ -237,14 +259,12 @@ class File:
|
||||||
class Gist(APIObject):
|
class Gist(APIObject):
|
||||||
__slots__ = (
|
__slots__ = (
|
||||||
'id',
|
'id',
|
||||||
'description',
|
|
||||||
'html_url',
|
'html_url',
|
||||||
'node_id',
|
'node_id',
|
||||||
'files',
|
'files',
|
||||||
'public',
|
'public',
|
||||||
'owner',
|
'owner',
|
||||||
'created_at',
|
'created_at',
|
||||||
'comments',
|
|
||||||
'truncated',
|
'truncated',
|
||||||
)
|
)
|
||||||
def __init__(self, response: dict, _http: http) -> None:
|
def __init__(self, response: dict, _http: http) -> None:
|
||||||
|
@ -264,6 +284,22 @@ class Gist(APIObject):
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
return f'<{self.__class__.__name__}; id: {self.id}, owner: {self.owner}, created_at: {self.created_at}>'
|
return f'<{self.__class__.__name__}; id: {self.id}, owner: {self.owner}, created_at: {self.created_at}>'
|
||||||
|
|
||||||
|
@property
|
||||||
|
def updated_at(self) -> str:
|
||||||
|
return dt_formatter(self._response.get('updated_at'))
|
||||||
|
|
||||||
|
@property
|
||||||
|
def comments(self) -> str:
|
||||||
|
return self._response.get('comments')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def discussion(self) -> str:
|
||||||
|
return self._response.get('discussion')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def raw(self) -> str:
|
||||||
|
return self._response
|
||||||
|
|
||||||
|
|
||||||
#=== Organization stuff ===#
|
#=== Organization stuff ===#
|
||||||
|
|
||||||
|
@ -271,7 +307,6 @@ class Organization(APIObject):
|
||||||
__slots__ = (
|
__slots__ = (
|
||||||
'login',
|
'login',
|
||||||
'id',
|
'id',
|
||||||
'html_url',
|
|
||||||
'is_verified',
|
'is_verified',
|
||||||
'public_repos',
|
'public_repos',
|
||||||
'public_gists',
|
'public_gists',
|
||||||
|
@ -298,4 +333,12 @@ class Organization(APIObject):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return f'<{self.__class__.__name__}; login: {self.login!r}, id: {self.id}, html_url: {self.html_url}, is_verified: {self.is_verified}, public_repos: {self.public_repos}, public_gists: {self.public_gists}, created_at: {self.created_at}>'
|
return f'<{self.__class__.__name__}; login: {self.login!r}, id: {self.id}, is_verified: {self.is_verified}, public_repos: {self.public_repos}, public_gists: {self.public_gists}, created_at: {self.created_at}>'
|
||||||
|
|
||||||
|
@property
|
||||||
|
def description(self):
|
||||||
|
return self._response.get('description')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def html_url(self):
|
||||||
|
return self._response.get('html_url')
|
Loading…
Add table
Add a link
Reference in a new issue