8000 Keep up with the API · n1k0/github3.py@7568e08 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7568e08

Browse files
committed
1 parent f91b9d2 commit 7568e08

File tree

4 files changed

+24
-12
lines changed

4 files changed

+24
-12
lines changed

github3/api.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ def search_issues(owner, repo, state, keyword):
296296
:param str repo: (required)
297297
:param str state: (required), accepted values: ('open', 'closed')
298298
:param str keyword: (required), what to search for
299+
:param int start_page: (optional), page to get (results come 100/page)
299300
:returns: list of :class:`LegacyIssue <github3.legacy.LegacyIssue>`\ s
300301
"""
301302
return gh.search_issues(owner, repo, state, keyword)
@@ -304,10 +305,9 @@ def search_issues(owner, repo, state, keyword):
304305
def search_repos(keyword, **params):
305306
"""Search all repositories by keyword.
306307
307-
:param keyword: (required)
308-
:type keyword: str
309-
:param params: (optional), filter by language and/or start_page
310-
:type params: dict
308+
:param str keyword: (required)
309+
:param str language: (optional), language to filter by
310+
:param int start_page: (optional), page to get (results come 100/page)
311311
:returns: list of :class:`LegacyRepo <github3.legacy.Leg 10000 acyRepo>`\ s
312312
"""
313313
return gh.search_repos(keyword, **params)
@@ -317,6 +317,7 @@ def search_users(keyword):
317317
"""Search all users by keyword.
318318
319319
:param str keyword: (required)
320+
:param int start_page: (optional), page to get (results come 100/page)
320321
:returns: list of :class:`LegacyUser <github3.legacy.LegacyUser>`\ s
321322
"""
322323
return gh.search_users(keyword)

github3/gists.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def fork(self):
154154
155155
:returns: :class:`Gist <Gist>` if successful, ``None`` otherwise
156156
"""
157-
url = self._api + '/fork'
157+
url = self._build_url('forks', base_url=self._api)
158158
json = self._json(self._post(url), 201)
159159
return Gist(json, self) if json else None
160160

github3/github.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -760,41 +760,51 @@ def repository(self, owner, repository):
760760
json = self._json(self._get(url), 200)
761761
return Repository(json, self) if json else None
762762

763-
def search_issues(self, owner, repo, state, keyword):
763+
def search_issues(self, owner, repo, state, keyword, start_page=0):
764764
"""Find issues by state and keyword.
765765
766766
:param str owner: (required)
767767
:param str repo: (required)
768768
:param str state: (required), accepted values: ('open', 'closed')
769769
:param str keyword: (required), what to search for
770+
:param int start_page: (optional), page to get (results come 100/page)
770771
:returns: list of :class:`LegacyIssue <github3.legacy.LegacyIssue>`\ s
771772
"""
773+
params = {} if int(start_page) > 0 else {'start_page': int(start_page)}
772774
url = self._build_url('legacy', 'issues', 'search', owner, repo,
773775
state, keyword)
774-
json = self._json(self._get(url), 200)
776+
json = self._json(self._get(url, params=params), 200)
775777
issues = json.get('issues', [])
776778
return [LegacyIssue(l, self) for l in issues]
777779

778-
def search_repos(self, keyword, **params):
780+
def search_repos(self, keyword, language='', start_page=0):
779781
"""Search all repositories by keyword.
780782
781783
:param str keyword: (required)
782-
:param dict params: (optional), filter by language and/or start_page
784+
:param str language: (optional), language to filter by
785+
:param int start_page: (optional), page to get (results come 100/page)
783786
:returns: list of :class:`LegacyRepo <github3.legacy.LegacyRepo>`\ s
784787
"""
785788
url = self._build_url('legacy', 'repos', 'search', keyword)
789+
params = {}
790+
if language:
791+
params['language'] = language
792+
if start_page > 0:
793+
params['start_page'] = start_page
786794
json = self._json(self._get(url, params=params), 200)
787795
repos = json.get('repositories', [])
788796
return [LegacyRepo(r, self) for r in repos]
789797

790-
def search_users(self, keyword):
798+
def search_users(self, keyword, start_page=0):
791799
"""Search all users by keyword.
792800
793801
:param str keyword: (required)
802+
:param int start_page: (optional), page to get (results come 100/page)
794803
:returns: list of :class:`LegacyUser <github3.legacy.LegacyUser>`\ s
795804
"""
805+
params = {} if int(start_page) > 0 else {'start_page': int(start_page)}
796806
url = self._build_url('legacy', 'user', 'search', str(keyword))
797-
json = self._json(self._get(url), 200)
807+
json = self._json(self._get(url, params=params), 200)
798808
users = json.get('users', [])
799809
return [LegacyUser(u, self) for u in users]
800810

github3/repos.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1521,7 +1521,8 @@ def test(self):
15211521
15221522
:returns: bool
15231523
"""
1524-
return self._boolean(self._post(self._api + '/test'), 204, 404)
1524+
url = self._build_url('tests', base_url=self._api)
1525+
return self._boolean(self._post(url), 204, 404)
15251526

15261527

15271528
class RepoTag(GitHubObject):

0 commit comments

Comments
 (0)
0