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

Commit9873f03

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

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
@@ -982,6 +982,52 @@ def repository(self, owner, repository):
982982
json=self._json(self._get(url),200)
983983
returnRepository(json,self)ifjsonelseNone
984984

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp