Add sorting capability to Organization.get_repos() (#1139)

This commit is contained in:
Geoffroy Jabouley
2019-06-20 15:51:55 +08:00
committed by Wan Liuyang
parent 4349bca136
commit ef6f009dc3
3 changed files with 24 additions and 1 deletions
+10 -1
View File
@@ -760,16 +760,25 @@ class Organization(github.GithubObject.CompletableGithubObject):
)
return github.Repository.Repository(self._requester, headers, data, completed=True)
def get_repos(self, type=github.GithubObject.NotSet):
def get_repos(self, type=github.GithubObject.NotSet, sort=github.GithubObject.NotSet, direction=github.GithubObject.NotSet):
"""
:calls: `GET /orgs/:org/repos <http://developer.github.com/v3/repos>`_
:param type: string ('all', 'public', 'private', 'forks', 'sources', 'member')
:param sort: string ('created', 'updated', 'pushed', 'full_name')
:param direction: string ('asc', desc')
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Repository.Repository`
"""
assert type is github.GithubObject.NotSet or isinstance(type, (str, unicode)), type
assert sort is github.GithubObject.NotSet or isinstance(sort, (str, unicode)), sort
assert direction is github.GithubObject.NotSet or isinstance(direction, (str, unicode)), direction
url_parameters = dict()
if type is not github.GithubObject.NotSet:
url_parameters["type"] = type
if sort is not github.GithubObject.NotSet:
url_parameters["sort"] = sort
if direction is not github.GithubObject.NotSet:
url_parameters["direction"] = direction
return github.PaginatedList.PaginatedList(
github.Repository.Repository,
self._requester,