Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0a1e00f

Browse files
committed
Add repository search
I am not the happiest with how the endpoint behaves, but I have an idea
1 parent5084df7 commit0a1e00f

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

‎github3/github.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -984,6 +984,52 @@ def repository(self, owner, repository):
984984
json=self._json(self._get(url),200)
985985
returnRepository(json,self)ifjsonelseNone
986986

987+
defsearch_repositories(self,query,sort=None,order=None,
988+
per_page=None,text_match=False):
989+
"""Find repositories via various criteria.
990+
991+
The query can contain any combination of the following supported
992+
qualifers:
993+
994+
- ``in`` Qualifies which fields are searched. With this qualifier you
995+
can restrict the search to just the repository name, description,
996+
readme, or any combination of these.
997+
- ``size`` Finds repositories that match a certain size (in
998+
kilobytes).
999+
- ``forks`` Filters repositories based on the number of forks, and/or
1000+
whether forked repositories should be included in the results at
1001+
all.
1002+
- ``created`` or ``pushed`` Filters repositories based on times of
1003+
creation, or when they were last updated.
1004+
- ``user`` or ``repo`` Limits searches to a specific user or
1005+
repository.
1006+
- ``language`` Searches repositories based on the language they're
1007+
written in.
1008+
- ``stars`` Searches repositories based on the number of stars.
1009+
1010+
:param str query: (required), a valid query as described above, e.g.,
1011+
``tetris language:assembly``
1012+
:param str sort: (optional), how the results should be sorted;
1013+
options: ``stars``, ``forks``, ``updated``; default: best match
1014+
:param str order: (optional), the direction of the sorted results,
1015+
options: ``asc``, ``desc``; default: ``desc``
1016+
:param int per_page: (optional)
1017+
:param bool text_match: (optional), if True, return matching search
1018+
terms. See http://git.io/4ct1eQ for more information
1019+
:return: dict
1020+
"""
1021+
# TODO Describe the dictionary being returned
1022+
params= {'q':query}
1023+
1024+
ifsortin ('stars','forks','updated'):
1025+
params['sort']=sort
1026+
1027+
iforderin ('asc','desc'):
1028+
params['order']=order
1029+
1030+
url=self._build_url('search','repositories')
1031+
returnself._json(self._get(url,params=params),200)
1032+
9871033
defset_client_id(self,id,secret):
9881034
"""Allows the developer to set their client_id and client_secret for
9891035
their OAuth application.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp