@@ -984,6 +984,52 @@ def repository(self, owner, repository):
984
984
json = self ._json (self ._get (url ),200 )
985
985
return Repository (json ,self )if json else None
986
986
987
+ def search_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
+ if sort in ('stars' ,'forks' ,'updated' ):
1025
+ params ['sort' ]= sort
1026
+
1027
+ if order in ('asc' ,'desc' ):
1028
+ params ['order' ]= order
1029
+
1030
+ url = self ._build_url ('search' ,'repositories' )
1031
+ return self ._json (self ._get (url ,params = params ),200 )
1032
+
987
1033
def set_client_id (self ,id ,secret ):
988
1034
"""Allows the developer to set their client_id and client_secret for
989
1035
their OAuth application.