Skip to content
This repository was archived by the owner on May 22, 2021. It is now read-only.

Commit c74e5c0

Browse files
committed
Update search submodule for consistency with docs
1 parent ab727a1 commit c74e5c0

File tree

4 files changed

+97
-43
lines changed

4 files changed

+97
-43
lines changed

github3/github.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1320,7 +1320,7 @@ def search_code(self, query, sort=None, order=None, per_page=None,
13201320

13211321
def search_issues(self, query, sort=None, order=None, per_page=None,
13221322
text_match=False, number=-1, etag=None):
1323-
"""Find issues by state and keyword
1323+
"""Find issues by state and keyword.
13241324
13251325
The query can contain any combination of the following supported
13261326
qualifers:

github3/search/code.py

+45-20
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,65 @@
11
# -*- coding: utf-8 -*-
2+
"""Code search results implementation."""
23
from __future__ import unicode_literals
34

45
from .. import models
56
from .. import repos
67

78

89
class CodeSearchResult(models.GitHubCore):
10+
"""A representation of a code search result from the API.
911
10-
def _update_attributes(self, data):
11-
self._api = self._get_attribute(data, 'url')
12+
This object has the following attributes:
13+
14+
.. attribute:: git_url
15+
16+
The URL to retrieve the blob via Git
17+
18+
.. attribute:: html_url
19+
20+
The URL to view the blob found in a browser.
21+
22+
.. attribute:: name
23+
24+
The name of the file where the search result was found.
1225
13-
#: Filename the match occurs in
14-
self.name = self._get_attribute(data, 'name')
26+
.. attribute:: path
1527
16-
#: Path in the repository to the file
17-
self.path = self._get_attribute(data, 'path')
28+
The path in the repository to the file containing the result.
1829
19-
#: SHA in which the code can be found
20-
self.sha = self._get_attribute(data, 'sha')
30+
.. attribute:: repository
2131
22-
#: URL to the Git blob endpoint
23-
self.git_url = self._get_attribute(data, 'git_url')
32+
A :class:`~github3.repos.repo.ShortRepository` representing the
33+
repository in which the result was found.
2434
25-
#: URL to the HTML view of the blob
26-
self.html_url = self._get_attribute(data, 'html_url')
35+
.. attribute:: score
2736
28-
#: Repository the code snippet belongs to
29-
self.repository = self._class_attribute(
30-
data, 'repository', repos.ShortRepository, self
31-
)
37+
The confidence score assigned to the result.
3238
33-
#: Score of the result
34-
self.score = self._get_attribute(data, 'score')
39+
.. attribute:: sha
3540
36-
#: Text matches
37-
self.text_matches = self._get_attribute(data, 'text_matches', [])
41+
The SHA1 of the blob in which the code can be found.
42+
43+
.. attribute:: text_matches
44+
45+
A list of the text matches in the blob that generated this result.
46+
47+
.. note::
48+
49+
To receive these, you must pass ``text_match=True`` to
50+
:meth:`~github3.github.GitHub.search_code`.
51+
"""
52+
53+
def _update_attributes(self, data):
54+
self._api = data['url']
55+
self.git_url = data['git_url']
56+
self.html_url = data['html_url']
57+
self.name = data['name']
58+
self.path = data['path']
59+
self.repository = repos.ShortRepository(data['repository'], self)
60+
self.score = data['score']
61+
self.sha = data['sha']
62+
self.text_matches = data.get('text_matches', [])
3863

3964
def _repr(self):
4065
return '<CodeSearchResult [{0}]>'.format(self.path)

github3/search/issue.py

+25-11
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,39 @@
11
# -*- coding: utf-8 -*-
2+
"""Issue search results implementation."""
23
from __future__ import unicode_literals
34

45
from ..models import GitHubCore
56
from ..issues import ShortIssue
67

78

89
class IssueSearchResult(GitHubCore):
9-
def _update_attributes(self, data):
10-
result = data.copy()
10+
"""A representation of a search result containing an issue.
11+
12+
This object has the following attributes:
13+
14+
.. attribute:: issue
15+
16+
A :class:`~github3.issues.issue.ShortIssue` representing the issue
17+
found in this search result.
18+
19+
.. attribute:: score
1120
12-
#: Score of the result
13-
self.score = self._get_attribute(result, 'score')
14-
if 'score' in result:
15-
del result['score']
21+
The confidence score of this search result.
1622
17-
#: Text matches
18-
self.text_matches = self._get_attribute(result, 'text_matches', [])
19-
if 'text_matches' in result:
20-
del result['text_matches']
23+
.. attribute:: text_matches
2124
22-
#: Issue object
25+
A list of matches in the issue for this search result.
26+
27+
.. note::
28+
29+
To receive these, you must pass ``text_match=True`` to
30+
:meth:`~github3.github.GitHub.search_issues`.
31+
"""
32+
33+
def _update_attributes(self, data):
34+
result = data.copy()
35+
self.score = result.pop('score')
36+
self.text_matches = result.pop('text_matches', [])
2337
self.issue = ShortIssue(result, self)
2438

2539
def _repr(self):

github3/search/repository.py

+26-11
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,40 @@
11
# -*- coding: utf-8 -*-
2+
"""Repository search results implementation."""
23
from __future__ import unicode_literals
34

45
from .. import models
56
from .. import repos
67

78

89
class RepositorySearchResult(models.GitHubCore):
9-
def _update_attributes(self, data):
10-
result = data.copy()
10+
"""A representation of a search result containing a repository.
11+
12+
This object has the following attributes::
13+
14+
.. attribute:: repository
15+
16+
A :class:`~github3.repos.repo.ShortRepository` representing the
17+
repository found by the search.
18+
19+
.. attribute:: score
1120
12-
#: Score of the result
13-
self.score = self._get_attribute(result, 'score')
14-
if 'score' in result:
15-
del result['score']
21+
The confidence score of this search result.
1622
17-
#: Text matches
18-
self.text_matches = self._get_attribute(result, 'text_matches', [])
19-
if 'text_matches' in result:
20-
del result['text_matches']
23+
.. attribute:: text_matches
2124
22-
#: Repository object
25+
A list of the text matches in the repository that generated this
26+
result.
27+
28+
.. note::
29+
30+
To receive these, you must pass ``text_match=True`` to
31+
:meth:`~github3.github.GitHub.search_code`.
32+
"""
33+
34+
def _update_attributes(self, data):
35+
result = data.copy()
36+
self.score = result.pop('score')
37+
self.text_matches = result.pop('text_matches', [])
2338
self.repository = repos.ShortRepository(result, self)
2439

2540
def _repr(self):

0 commit comments

Comments
 (0)