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