mirror of
https://github.com/status-im/PyGithub.git
synced 2026-09-01 03:11:09 +00:00
Add code search
Code search results are content resources with an embedded repository. The "content" and "encoding" attributes aren't returned and require completion.
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
################################################################################
|
||||
|
||||
import github.GithubObject
|
||||
import github.Repository
|
||||
|
||||
|
||||
class ContentFile(github.GithubObject.CompletableGithubObject):
|
||||
@@ -80,6 +81,17 @@ class ContentFile(github.GithubObject.CompletableGithubObject):
|
||||
self._completeIfNotSet(self._path)
|
||||
return self._path.value
|
||||
|
||||
@property
|
||||
def repository(self):
|
||||
"""
|
||||
:type: :class:`github.Repository.Repository`
|
||||
"""
|
||||
if self._repository is github.GithubObject.NotSet:
|
||||
# The repository was not set automatically, so it must be looked up by url.
|
||||
repo_url = "/".join(self.url.split("/")[:6])
|
||||
self._repository = github.GithubObject._ValuedAttribute(github.Repository.Repository(self._requester, self._headers, {'url': repo_url}, completed=False))
|
||||
return self._repository.value
|
||||
|
||||
@property
|
||||
def sha(self):
|
||||
"""
|
||||
@@ -119,6 +131,7 @@ class ContentFile(github.GithubObject.CompletableGithubObject):
|
||||
self._html_url = github.GithubObject.NotSet
|
||||
self._name = github.GithubObject.NotSet
|
||||
self._path = github.GithubObject.NotSet
|
||||
self._repository = github.GithubObject.NotSet
|
||||
self._sha = github.GithubObject.NotSet
|
||||
self._size = github.GithubObject.NotSet
|
||||
self._type = github.GithubObject.NotSet
|
||||
@@ -136,6 +149,8 @@ class ContentFile(github.GithubObject.CompletableGithubObject):
|
||||
self._name = self._makeStringAttribute(attributes["name"])
|
||||
if "path" in attributes: # pragma no branch
|
||||
self._path = self._makeStringAttribute(attributes["path"])
|
||||
if "repository" in attributes: # pragma no branch
|
||||
self._repository = self._makeClassAttribute(github.Repository.Repository, attributes["repository"])
|
||||
if "sha" in attributes: # pragma no branch
|
||||
self._sha = self._makeStringAttribute(attributes["sha"])
|
||||
if "size" in attributes: # pragma no branch
|
||||
|
||||
Reference in New Issue
Block a user