diff --git a/github/Consts.py b/github/Consts.py index d0125e99..9aead92e 100644 --- a/github/Consts.py +++ b/github/Consts.py @@ -89,3 +89,6 @@ mediaTypeOrganizationInvitationPreview = "application/vnd.github.dazzler-preview # https://developer.github.com/changes/2018-03-16-protected-branches-required-approving-reviews/ mediaTypeRequireMultipleApprovingReviews = "application/vnd.github.luke-cage-preview+json" + +# https://developer.github.com/v3/search/#highlighting-code-search-results-1 +highLightSearchPreview = "application/vnd.github.v3.text-match+json" diff --git a/github/ContentFile.py b/github/ContentFile.py index 345b6fc6..e597a099 100644 --- a/github/ContentFile.py +++ b/github/ContentFile.py @@ -165,8 +165,17 @@ class ContentFile(github.GithubObject.CompletableGithubObject): self._completeIfNotSet(self._url) return self._url.value + @property + def text_matches(self): + """ + :type: string + """ + self._completeIfNotSet(self._text_matches) + return self._text_matches.value + def _initAttributes(self): self._content = github.GithubObject.NotSet + self._text_matches = github.GithubObject.NotSet self._encoding = github.GithubObject.NotSet self._download_url = github.GithubObject.NotSet self._git_url = github.GithubObject.NotSet @@ -206,3 +215,5 @@ class ContentFile(github.GithubObject.CompletableGithubObject): self._type = self._makeStringAttribute(attributes["type"]) if "url" in attributes: # pragma no branch self._url = self._makeStringAttribute(attributes["url"]) + if "text_matches" in attributes: # pragma no branch + self._text_matches = self._makeListOfDictsAttribute(attributes["text_matches"]) diff --git a/github/GithubObject.py b/github/GithubObject.py index c3f26638..f1ffa752 100644 --- a/github/GithubObject.py +++ b/github/GithubObject.py @@ -188,6 +188,10 @@ class GithubObject(object): def _makeListOfIntsAttribute(value): return GithubObject.__makeSimpleListAttribute(value, int) + @staticmethod + def _makeListOfDictsAttribute(value): + return GithubObject.__makeSimpleListAttribute(value, dict) + @staticmethod def _makeListOfListOfStringsAttribute(value): return GithubObject.__makeSimpleListAttribute(value, list) diff --git a/github/MainClass.py b/github/MainClass.py index 40b19f3b..ec534e25 100644 --- a/github/MainClass.py +++ b/github/MainClass.py @@ -459,12 +459,13 @@ class Github(object): url_parameters ) - def search_code(self, query, sort=github.GithubObject.NotSet, order=github.GithubObject.NotSet, **qualifiers): + def search_code(self, query, sort=github.GithubObject.NotSet, order=github.GithubObject.NotSet, highlight=False, **qualifiers): """ :calls: `GET /search/code `_ :param query: string :param sort: string ('indexed') :param order: string ('asc', 'desc') + :param highlight: boolean (True, False) :param qualifiers: keyword dict query qualifiers :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.ContentFile.ContentFile` """ @@ -487,14 +488,16 @@ class Github(object): url_parameters["q"] = ' '.join(query_chunks) assert url_parameters["q"], "need at least one qualifier" + headers = {"Accept": Consts.highLightSearchPreview} if highlight else None + return github.PaginatedList.PaginatedList( github.ContentFile.ContentFile, self.__requester, "/search/code", - url_parameters + url_parameters, + headers=headers ) - def search_commits(self, query, sort=github.GithubObject.NotSet, order=github.GithubObject.NotSet, **qualifiers): """ :calls: `GET /search/commits `_ diff --git a/github/tests/ReplayData/Search.testSearchHighlightingCode.txt b/github/tests/ReplayData/Search.testSearchHighlightingCode.txt new file mode 100644 index 00000000..ae5f9d3f --- /dev/null +++ b/github/tests/ReplayData/Search.testSearchHighlightingCode.txt @@ -0,0 +1,11 @@ +https +GET +api.github.com +None +/search/code?sort=indexed&q=toto+user%3Ajacquev6&order=asc +{'Accept': 'application/vnd.github.v3.text-match+json', 'Authorization': 'token private_token_removed', 'User-Agent': 'PyGithub/Python'} +None +200 +[('Server', 'GitHub.com'), ('Date', 'Wed, 10 Oct 2018 08:34:18 GMT'), ('Content-Type', 'application/json; charset=utf-8'), ('Transfer-Encoding', 'chunked'), ('Status', '200 OK'), ('X-RateLimit-Limit', '30'), ('X-RateLimit-Remaining', '29'), ('X-RateLimit-Reset', '1539160518'), ('Cache-Control', 'no-cache'), ('X-OAuth-Scopes', 'admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion'), ('X-Accepted-OAuth-Scopes', ''), ('X-GitHub-Media-Type', 'github.v3; param=text-match; format=json'), ('Access-Control-Expose-Headers', 'ETag, Link, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval'), ('Access-Control-Allow-Origin', '*'), ('Strict-Transport-Security', 'max-age=31536000; includeSubdomains; preload'), ('X-Frame-Options', 'deny'), ('X-Content-Type-Options', 'nosniff'), ('X-XSS-Protection', '1; mode=block'), ('Referrer-Policy', 'origin-when-cross-origin, strict-origin-when-cross-origin'), ('Content-Security-Policy', "default-src 'none'"), ('Content-Encoding', 'gzip'), ('X-GitHub-Request-Id', 'FFBB:2B2B:33E8CC:62F0C0:5BBDB988')] +{"total_count":5,"incomplete_results":false,"items":[{"name":"record_replay.py","path":"MockMockMock/tests/record_replay.py","sha":"74b8d2a2274a74fb9a7b2155bb9fa67038110010","url":"https://api.github.com/repositories/6430524/contents/MockMockMock/tests/record_replay.py?ref=562a55542f55426f6853f3013309c85f402c359e","git_url":"https://api.github.com/repositories/6430524/git/blobs/74b8d2a2274a74fb9a7b2155bb9fa67038110010","html_url":"https://github.com/jacquev6/MockMockMock/blob/562a55542f55426f6853f3013309c85f402c359e/MockMockMock/tests/record_replay.py","repository":{"id":6430524,"node_id":"MDEwOlJlcG9zaXRvcnk2NDMwNTI0","name":"MockMockMock","full_name":"jacquev6/MockMockMock","private":false,"owner":{"login":"jacquev6","id":327146,"node_id":"MDQ6VXNlcjMyNzE0Ng==","avatar_url":"https://avatars1.githubusercontent.com/u/327146?v=4","gravatar_id":"","url":"https://api.github.com/users/jacquev6","html_url":"https://github.com/jacquev6","followers_url":"https://api.github.com/users/jacquev6/followers","following_url":"https://api.github.com/users/jacquev6/following{/other_user}","gists_url":"https://api.github.com/users/jacquev6/gists{/gist_id}","starred_url":"https://api.github.com/users/jacquev6/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacquev6/subscriptions","organizations_url":"https://api.github.com/users/jacquev6/orgs","repos_url":"https://api.github.com/users/jacquev6/repos","events_url":"https://api.github.com/users/jacquev6/events{/privacy}","received_events_url":"https://api.github.com/users/jacquev6/received_events","type":"User","site_admin":false},"html_url":"https://github.com/jacquev6/MockMockMock","description":"Python mock library focusing on very explicit definition of the mocks' behaviour","fork":false,"url":"https://api.github.com/repos/jacquev6/MockMockMock","forks_url":"https://api.github.com/repos/jacquev6/MockMockMock/forks","keys_url":"https://api.github.com/repos/jacquev6/MockMockMock/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jacquev6/MockMockMock/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jacquev6/MockMockMock/teams","hooks_url":"https://api.github.com/repos/jacquev6/MockMockMock/hooks","issue_events_url":"https://api.github.com/repos/jacquev6/MockMockMock/issues/events{/number}","events_url":"https://api.github.com/repos/jacquev6/MockMockMock/events","assignees_url":"https://api.github.com/repos/jacquev6/MockMockMock/assignees{/user}","branches_url":"https://api.github.com/repos/jacquev6/MockMockMock/branches{/branch}","tags_url":"https://api.github.com/repos/jacquev6/MockMockMock/tags","blobs_url":"https://api.github.com/repos/jacquev6/MockMockMock/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jacquev6/MockMockMock/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jacquev6/MockMockMock/git/refs{/sha}","trees_url":"https://api.github.com/repos/jacquev6/MockMockMock/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jacquev6/MockMockMock/statuses/{sha}","languages_url":"https://api.github.com/repos/jacquev6/MockMockMock/languages","stargazers_url":"https://api.github.com/repos/jacquev6/MockMockMock/stargazers","contributors_url":"https://api.github.com/repos/jacquev6/MockMockMock/contributors","subscribers_url":"https://api.github.com/repos/jacquev6/MockMockMock/subscribers","subscription_url":"https://api.github.com/repos/jacquev6/MockMockMock/subscription","commits_url":"https://api.github.com/repos/jacquev6/MockMockMock/commits{/sha}","git_commits_url":"https://api.github.com/repos/jacquev6/MockMockMock/git/commits{/sha}","comments_url":"https://api.github.com/repos/jacquev6/MockMockMock/comments{/number}","issue_comment_url":"https://api.github.com/repos/jacquev6/MockMockMock/issues/comments{/number}","contents_url":"https://api.github.com/repos/jacquev6/MockMockMock/contents/{+path}","compare_url":"https://api.github.com/repos/jacquev6/MockMockMock/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jacquev6/MockMockMock/merges","archive_url":"https://api.github.com/repos/jacquev6/MockMockMock/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jacquev6/MockMockMock/downloads","issues_url":"https://api.github.com/repos/jacquev6/MockMockMock/issues{/number}","pulls_url":"https://api.github.com/repos/jacquev6/MockMockMock/pulls{/number}","milestones_url":"https://api.github.com/repos/jacquev6/MockMockMock/milestones{/number}","notifications_url":"https://api.github.com/repos/jacquev6/MockMockMock/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jacquev6/MockMockMock/labels{/name}","releases_url":"https://api.github.com/repos/jacquev6/MockMockMock/releases{/id}","deployments_url":"https://api.github.com/repos/jacquev6/MockMockMock/deployments"},"score":14.030813,"text_matches":[{"object_url":"https://api.github.com/repositories/6430524/contents/MockMockMock/tests/record_replay.py?ref=562a55542f55426f6853f3013309c85f402c359e","object_type":"FileContent","property":"content","fragment":".assertEqual(\n self.recorded.instance_method(42, 43, 44, 45, toto=46, tutu=47","matches":[{"text":"toto","indices":[72,76]}]},{"object_url":"https://api.github.com/repositories/6430524/contents/MockMockMock/tests/record_replay.py?ref=562a55542f55426f6853f3013309c85f402c359e","object_type":"FileContent","property":"content","fragment":"),\n \"(42, 43, (44, 45), [('toto', 46), ('tutu', 47)])\"\n )\n self.assertEqual","matches":[{"text":"toto","indices":[38,42]}]}]},{"name":"system_calls.py","path":"MockMockMock/tests/system_calls.py","sha":"2d2cba5658372ed8453cc9491b30eed01d66a25c","url":"https://api.github.com/repositories/6430524/contents/MockMockMock/tests/system_calls.py?ref=562a55542f55426f6853f3013309c85f402c359e","git_url":"https://api.github.com/repositories/6430524/git/blobs/2d2cba5658372ed8453cc9491b30eed01d66a25c","html_url":"https://github.com/jacquev6/MockMockMock/blob/562a55542f55426f6853f3013309c85f402c359e/MockMockMock/tests/system_calls.py","repository":{"id":6430524,"node_id":"MDEwOlJlcG9zaXRvcnk2NDMwNTI0","name":"MockMockMock","full_name":"jacquev6/MockMockMock","private":false,"owner":{"login":"jacquev6","id":327146,"node_id":"MDQ6VXNlcjMyNzE0Ng==","avatar_url":"https://avatars1.githubusercontent.com/u/327146?v=4","gravatar_id":"","url":"https://api.github.com/users/jacquev6","html_url":"https://github.com/jacquev6","followers_url":"https://api.github.com/users/jacquev6/followers","following_url":"https://api.github.com/users/jacquev6/following{/other_user}","gists_url":"https://api.github.com/users/jacquev6/gists{/gist_id}","starred_url":"https://api.github.com/users/jacquev6/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacquev6/subscriptions","organizations_url":"https://api.github.com/users/jacquev6/orgs","repos_url":"https://api.github.com/users/jacquev6/repos","events_url":"https://api.github.com/users/jacquev6/events{/privacy}","received_events_url":"https://api.github.com/users/jacquev6/received_events","type":"User","site_admin":false},"html_url":"https://github.com/jacquev6/MockMockMock","description":"Python mock library focusing on very explicit definition of the mocks' behaviour","fork":false,"url":"https://api.github.com/repos/jacquev6/MockMockMock","forks_url":"https://api.github.com/repos/jacquev6/MockMockMock/forks","keys_url":"https://api.github.com/repos/jacquev6/MockMockMock/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jacquev6/MockMockMock/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jacquev6/MockMockMock/teams","hooks_url":"https://api.github.com/repos/jacquev6/MockMockMock/hooks","issue_events_url":"https://api.github.com/repos/jacquev6/MockMockMock/issues/events{/number}","events_url":"https://api.github.com/repos/jacquev6/MockMockMock/events","assignees_url":"https://api.github.com/repos/jacquev6/MockMockMock/assignees{/user}","branches_url":"https://api.github.com/repos/jacquev6/MockMockMock/branches{/branch}","tags_url":"https://api.github.com/repos/jacquev6/MockMockMock/tags","blobs_url":"https://api.github.com/repos/jacquev6/MockMockMock/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jacquev6/MockMockMock/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jacquev6/MockMockMock/git/refs{/sha}","trees_url":"https://api.github.com/repos/jacquev6/MockMockMock/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jacquev6/MockMockMock/statuses/{sha}","languages_url":"https://api.github.com/repos/jacquev6/MockMockMock/languages","stargazers_url":"https://api.github.com/repos/jacquev6/MockMockMock/stargazers","contributors_url":"https://api.github.com/repos/jacquev6/MockMockMock/contributors","subscribers_url":"https://api.github.com/repos/jacquev6/MockMockMock/subscribers","subscription_url":"https://api.github.com/repos/jacquev6/MockMockMock/subscription","commits_url":"https://api.github.com/repos/jacquev6/MockMockMock/commits{/sha}","git_commits_url":"https://api.github.com/repos/jacquev6/MockMockMock/git/commits{/sha}","comments_url":"https://api.github.com/repos/jacquev6/MockMockMock/comments{/number}","issue_comment_url":"https://api.github.com/repos/jacquev6/MockMockMock/issues/comments{/number}","contents_url":"https://api.github.com/repos/jacquev6/MockMockMock/contents/{+path}","compare_url":"https://api.github.com/repos/jacquev6/MockMockMock/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jacquev6/MockMockMock/merges","archive_url":"https://api.github.com/repos/jacquev6/MockMockMock/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jacquev6/MockMockMock/downloads","issues_url":"https://api.github.com/repos/jacquev6/MockMockMock/issues{/number}","pulls_url":"https://api.github.com/repos/jacquev6/MockMockMock/pulls{/number}","milestones_url":"https://api.github.com/repos/jacquev6/MockMockMock/milestones{/number}","notifications_url":"https://api.github.com/repos/jacquev6/MockMockMock/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jacquev6/MockMockMock/labels{/name}","releases_url":"https://api.github.com/repos/jacquev6/MockMockMock/releases{/id}","deployments_url":"https://api.github.com/repos/jacquev6/MockMockMock/deployments"},"score":13.455629,"text_matches":[{"object_url":"https://api.github.com/repositories/6430524/contents/MockMockMock/tests/system_calls.py?ref=562a55542f55426f6853f3013309c85f402c359e","object_type":"FileContent","property":"content","fragment":"\", \"toto\"]), b\"toto\\n\")\n\n def test_mock_unexisting_thing(self):\n with self.assertRaises","matches":[{"text":"toto","indices":[4,8]},{"text":"toto","indices":[15,19]}]}]},{"name":"create_table.py","path":"LowVoltage/actions/create_table.py","sha":"7aef3c351c905263a37ef028d9916572ecabb206","url":"https://api.github.com/repositories/24800231/contents/LowVoltage/actions/create_table.py?ref=aa9c3653e54f2ccda3db0ed647ba9ad5e5657ea3","git_url":"https://api.github.com/repositories/24800231/git/blobs/7aef3c351c905263a37ef028d9916572ecabb206","html_url":"https://github.com/jacquev6/LowVoltage/blob/aa9c3653e54f2ccda3db0ed647ba9ad5e5657ea3/LowVoltage/actions/create_table.py","repository":{"id":24800231,"node_id":"MDEwOlJlcG9zaXRvcnkyNDgwMDIzMQ==","name":"LowVoltage","full_name":"jacquev6/LowVoltage","private":false,"owner":{"login":"jacquev6","id":327146,"node_id":"MDQ6VXNlcjMyNzE0Ng==","avatar_url":"https://avatars1.githubusercontent.com/u/327146?v=4","gravatar_id":"","url":"https://api.github.com/users/jacquev6","html_url":"https://github.com/jacquev6","followers_url":"https://api.github.com/users/jacquev6/followers","following_url":"https://api.github.com/users/jacquev6/following{/other_user}","gists_url":"https://api.github.com/users/jacquev6/gists{/gist_id}","starred_url":"https://api.github.com/users/jacquev6/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacquev6/subscriptions","organizations_url":"https://api.github.com/users/jacquev6/orgs","repos_url":"https://api.github.com/users/jacquev6/repos","events_url":"https://api.github.com/users/jacquev6/events{/privacy}","received_events_url":"https://api.github.com/users/jacquev6/received_events","type":"User","site_admin":false},"html_url":"https://github.com/jacquev6/LowVoltage","description":"Standalone DynamoDB Python client not hiding any feature","fork":false,"url":"https://api.github.com/repos/jacquev6/LowVoltage","forks_url":"https://api.github.com/repos/jacquev6/LowVoltage/forks","keys_url":"https://api.github.com/repos/jacquev6/LowVoltage/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jacquev6/LowVoltage/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jacquev6/LowVoltage/teams","hooks_url":"https://api.github.com/repos/jacquev6/LowVoltage/hooks","issue_events_url":"https://api.github.com/repos/jacquev6/LowVoltage/issues/events{/number}","events_url":"https://api.github.com/repos/jacquev6/LowVoltage/events","assignees_url":"https://api.github.com/repos/jacquev6/LowVoltage/assignees{/user}","branches_url":"https://api.github.com/repos/jacquev6/LowVoltage/branches{/branch}","tags_url":"https://api.github.com/repos/jacquev6/LowVoltage/tags","blobs_url":"https://api.github.com/repos/jacquev6/LowVoltage/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jacquev6/LowVoltage/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jacquev6/LowVoltage/git/refs{/sha}","trees_url":"https://api.github.com/repos/jacquev6/LowVoltage/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jacquev6/LowVoltage/statuses/{sha}","languages_url":"https://api.github.com/repos/jacquev6/LowVoltage/languages","stargazers_url":"https://api.github.com/repos/jacquev6/LowVoltage/stargazers","contributors_url":"https://api.github.com/repos/jacquev6/LowVoltage/contributors","subscribers_url":"https://api.github.com/repos/jacquev6/LowVoltage/subscribers","subscription_url":"https://api.github.com/repos/jacquev6/LowVoltage/subscription","commits_url":"https://api.github.com/repos/jacquev6/LowVoltage/commits{/sha}","git_commits_url":"https://api.github.com/repos/jacquev6/LowVoltage/git/commits{/sha}","comments_url":"https://api.github.com/repos/jacquev6/LowVoltage/comments{/number}","issue_comment_url":"https://api.github.com/repos/jacquev6/LowVoltage/issues/comments{/number}","contents_url":"https://api.github.com/repos/jacquev6/LowVoltage/contents/{+path}","compare_url":"https://api.github.com/repos/jacquev6/LowVoltage/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jacquev6/LowVoltage/merges","archive_url":"https://api.github.com/repos/jacquev6/LowVoltage/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jacquev6/LowVoltage/downloads","issues_url":"https://api.github.com/repos/jacquev6/LowVoltage/issues{/number}","pulls_url":"https://api.github.com/repos/jacquev6/LowVoltage/pulls{/number}","milestones_url":"https://api.github.com/repos/jacquev6/LowVoltage/milestones{/number}","notifications_url":"https://api.github.com/repos/jacquev6/LowVoltage/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jacquev6/LowVoltage/labels{/name}","releases_url":"https://api.github.com/repos/jacquev6/LowVoltage/releases{/id}","deployments_url":"https://api.github.com/repos/jacquev6/LowVoltage/deployments"},"score":8.286316,"text_matches":[{"object_url":"https://api.github.com/repositories/24800231/contents/LowVoltage/actions/create_table.py?ref=aa9c3653e54f2ccda3db0ed647ba9ad5e5657ea3","object_type":"FileContent","property":"content","fragment":"(\n CreateTable(\"Foo\").global_secondary_index(\"foo\").project(\"toto\", \"titi\").project([\"tutu\"]).payload","matches":[{"text":"toto","indices":[72,76]}]},{"object_url":"https://api.github.com/repositories/24800231/contents/LowVoltage/actions/create_table.py?ref=aa9c3653e54f2ccda3db0ed647ba9ad5e5657ea3","object_type":"FileContent","property":"content","fragment":"\": [\n {\"IndexName\": \"foo\", \"Projection\": {\"ProjectionType\": \"INCLUDE\", \"NonKeyAttributes\": [\"toto","matches":[{"text":"toto","indices":[112,116]}]}]},{"name":"test_create_table.py","path":"LowVoltage/actions/tests/integ/test_create_table.py","sha":"f2df1efd748a20730dc5fb75059d1b0d986ddb71","url":"https://api.github.com/repositories/24800231/contents/LowVoltage/actions/tests/integ/test_create_table.py?ref=aa9c3653e54f2ccda3db0ed647ba9ad5e5657ea3","git_url":"https://api.github.com/repositories/24800231/git/blobs/f2df1efd748a20730dc5fb75059d1b0d986ddb71","html_url":"https://github.com/jacquev6/LowVoltage/blob/aa9c3653e54f2ccda3db0ed647ba9ad5e5657ea3/LowVoltage/actions/tests/integ/test_create_table.py","repository":{"id":24800231,"node_id":"MDEwOlJlcG9zaXRvcnkyNDgwMDIzMQ==","name":"LowVoltage","full_name":"jacquev6/LowVoltage","private":false,"owner":{"login":"jacquev6","id":327146,"node_id":"MDQ6VXNlcjMyNzE0Ng==","avatar_url":"https://avatars1.githubusercontent.com/u/327146?v=4","gravatar_id":"","url":"https://api.github.com/users/jacquev6","html_url":"https://github.com/jacquev6","followers_url":"https://api.github.com/users/jacquev6/followers","following_url":"https://api.github.com/users/jacquev6/following{/other_user}","gists_url":"https://api.github.com/users/jacquev6/gists{/gist_id}","starred_url":"https://api.github.com/users/jacquev6/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacquev6/subscriptions","organizations_url":"https://api.github.com/users/jacquev6/orgs","repos_url":"https://api.github.com/users/jacquev6/repos","events_url":"https://api.github.com/users/jacquev6/events{/privacy}","received_events_url":"https://api.github.com/users/jacquev6/received_events","type":"User","site_admin":false},"html_url":"https://github.com/jacquev6/LowVoltage","description":"Standalone DynamoDB Python client not hiding any feature","fork":false,"url":"https://api.github.com/repos/jacquev6/LowVoltage","forks_url":"https://api.github.com/repos/jacquev6/LowVoltage/forks","keys_url":"https://api.github.com/repos/jacquev6/LowVoltage/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jacquev6/LowVoltage/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jacquev6/LowVoltage/teams","hooks_url":"https://api.github.com/repos/jacquev6/LowVoltage/hooks","issue_events_url":"https://api.github.com/repos/jacquev6/LowVoltage/issues/events{/number}","events_url":"https://api.github.com/repos/jacquev6/LowVoltage/events","assignees_url":"https://api.github.com/repos/jacquev6/LowVoltage/assignees{/user}","branches_url":"https://api.github.com/repos/jacquev6/LowVoltage/branches{/branch}","tags_url":"https://api.github.com/repos/jacquev6/LowVoltage/tags","blobs_url":"https://api.github.com/repos/jacquev6/LowVoltage/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jacquev6/LowVoltage/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jacquev6/LowVoltage/git/refs{/sha}","trees_url":"https://api.github.com/repos/jacquev6/LowVoltage/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jacquev6/LowVoltage/statuses/{sha}","languages_url":"https://api.github.com/repos/jacquev6/LowVoltage/languages","stargazers_url":"https://api.github.com/repos/jacquev6/LowVoltage/stargazers","contributors_url":"https://api.github.com/repos/jacquev6/LowVoltage/contributors","subscribers_url":"https://api.github.com/repos/jacquev6/LowVoltage/subscribers","subscription_url":"https://api.github.com/repos/jacquev6/LowVoltage/subscription","commits_url":"https://api.github.com/repos/jacquev6/LowVoltage/commits{/sha}","git_commits_url":"https://api.github.com/repos/jacquev6/LowVoltage/git/commits{/sha}","comments_url":"https://api.github.com/repos/jacquev6/LowVoltage/comments{/number}","issue_comment_url":"https://api.github.com/repos/jacquev6/LowVoltage/issues/comments{/number}","contents_url":"https://api.github.com/repos/jacquev6/LowVoltage/contents/{+path}","compare_url":"https://api.github.com/repos/jacquev6/LowVoltage/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jacquev6/LowVoltage/merges","archive_url":"https://api.github.com/repos/jacquev6/LowVoltage/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jacquev6/LowVoltage/downloads","issues_url":"https://api.github.com/repos/jacquev6/LowVoltage/issues{/number}","pulls_url":"https://api.github.com/repos/jacquev6/LowVoltage/pulls{/number}","milestones_url":"https://api.github.com/repos/jacquev6/LowVoltage/milestones{/number}","notifications_url":"https://api.github.com/repos/jacquev6/LowVoltage/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jacquev6/LowVoltage/labels{/name}","releases_url":"https://api.github.com/repos/jacquev6/LowVoltage/releases{/id}","deployments_url":"https://api.github.com/repos/jacquev6/LowVoltage/deployments"},"score":11.386696,"text_matches":[{"object_url":"https://api.github.com/repositories/24800231/contents/LowVoltage/actions/tests/integ/test_create_table.py?ref=aa9c3653e54f2ccda3db0ed647ba9ad5e5657ea3","object_type":"FileContent","property":"content","fragment":"(1, 2)\n .global_secondary_index(\"the_gsi\")\n .hash_key(\"hh\", _lv.STRING)\n .project(\"toto","matches":[{"text":"toto","indices":[128,132]}]},{"object_url":"https://api.github.com/repositories/24800231/contents/LowVoltage/actions/tests/integ/test_create_table.py?ref=aa9c3653e54f2ccda3db0ed647ba9ad5e5657ea3","object_type":"FileContent","property":"content","fragment":"(r.table_description.global_secondary_indexes[0].projection.non_key_attributes[0], \"toto\")\n self","matches":[{"text":"toto","indices":[84,88]}]}]},{"name":"data.json","path":"test/data/data.json","sha":"e24a6211264b282e8f60f884722c5f9f1af81c2b","url":"https://api.github.com/repositories/140828333/contents/test/data/data.json?ref=5475c2b8294f90e6b446a0bd334987f0e5ed8ef1","git_url":"https://api.github.com/repositories/140828333/git/blobs/e24a6211264b282e8f60f884722c5f9f1af81c2b","html_url":"https://github.com/jacquev6/splight.fr-generator/blob/5475c2b8294f90e6b446a0bd334987f0e5ed8ef1/test/data/data.json","repository":{"id":140828333,"node_id":"MDEwOlJlcG9zaXRvcnkxNDA4MjgzMzM=","name":"splight.fr-generator","full_name":"jacquev6/splight.fr-generator","private":false,"owner":{"login":"jacquev6","id":327146,"node_id":"MDQ6VXNlcjMyNzE0Ng==","avatar_url":"https://avatars1.githubusercontent.com/u/327146?v=4","gravatar_id":"","url":"https://api.github.com/users/jacquev6","html_url":"https://github.com/jacquev6","followers_url":"https://api.github.com/users/jacquev6/followers","following_url":"https://api.github.com/users/jacquev6/following{/other_user}","gists_url":"https://api.github.com/users/jacquev6/gists{/gist_id}","starred_url":"https://api.github.com/users/jacquev6/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacquev6/subscriptions","organizations_url":"https://api.github.com/users/jacquev6/orgs","repos_url":"https://api.github.com/users/jacquev6/repos","events_url":"https://api.github.com/users/jacquev6/events{/privacy}","received_events_url":"https://api.github.com/users/jacquev6/received_events","type":"User","site_admin":false},"html_url":"https://github.com/jacquev6/splight.fr-generator","description":null,"fork":false,"url":"https://api.github.com/repos/jacquev6/splight.fr-generator","forks_url":"https://api.github.com/repos/jacquev6/splight.fr-generator/forks","keys_url":"https://api.github.com/repos/jacquev6/splight.fr-generator/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jacquev6/splight.fr-generator/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jacquev6/splight.fr-generator/teams","hooks_url":"https://api.github.com/repos/jacquev6/splight.fr-generator/hooks","issue_events_url":"https://api.github.com/repos/jacquev6/splight.fr-generator/issues/events{/number}","events_url":"https://api.github.com/repos/jacquev6/splight.fr-generator/events","assignees_url":"https://api.github.com/repos/jacquev6/splight.fr-generator/assignees{/user}","branches_url":"https://api.github.com/repos/jacquev6/splight.fr-generator/branches{/branch}","tags_url":"https://api.github.com/repos/jacquev6/splight.fr-generator/tags","blobs_url":"https://api.github.com/repos/jacquev6/splight.fr-generator/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jacquev6/splight.fr-generator/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jacquev6/splight.fr-generator/git/refs{/sha}","trees_url":"https://api.github.com/repos/jacquev6/splight.fr-generator/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jacquev6/splight.fr-generator/statuses/{sha}","languages_url":"https://api.github.com/repos/jacquev6/splight.fr-generator/languages","stargazers_url":"https://api.github.com/repos/jacquev6/splight.fr-generator/stargazers","contributors_url":"https://api.github.com/repos/jacquev6/splight.fr-generator/contributors","subscribers_url":"https://api.github.com/repos/jacquev6/splight.fr-generator/subscribers","subscription_url":"https://api.github.com/repos/jacquev6/splight.fr-generator/subscription","commits_url":"https://api.github.com/repos/jacquev6/splight.fr-generator/commits{/sha}","git_commits_url":"https://api.github.com/repos/jacquev6/splight.fr-generator/git/commits{/sha}","comments_url":"https://api.github.com/repos/jacquev6/splight.fr-generator/comments{/number}","issue_comment_url":"https://api.github.com/repos/jacquev6/splight.fr-generator/issues/comments{/number}","contents_url":"https://api.github.com/repos/jacquev6/splight.fr-generator/contents/{+path}","compare_url":"https://api.github.com/repos/jacquev6/splight.fr-generator/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jacquev6/splight.fr-generator/merges","archive_url":"https://api.github.com/repos/jacquev6/splight.fr-generator/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jacquev6/splight.fr-generator/downloads","issues_url":"https://api.github.com/repos/jacquev6/splight.fr-generator/issues{/number}","pulls_url":"https://api.github.com/repos/jacquev6/splight.fr-generator/pulls{/number}","milestones_url":"https://api.github.com/repos/jacquev6/splight.fr-generator/milestones{/number}","notifications_url":"https://api.github.com/repos/jacquev6/splight.fr-generator/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jacquev6/splight.fr-generator/labels{/name}","releases_url":"https://api.github.com/repos/jacquev6/splight.fr-generator/releases{/id}","deployments_url":"https://api.github.com/repos/jacquev6/splight.fr-generator/deployments"},"score":10.615608,"text_matches":[{"object_url":"https://api.github.com/repositories/140828333/contents/test/data/data.json?ref=5475c2b8294f90e6b446a0bd334987f0e5ed8ef1","object_type":"FileContent","property":"content","fragment":" laborum.\"\n ],\n \"name\": \"Artiste 1\",\n \"website\": \"https://google.fr/search?q=toto","matches":[{"text":"toto","indices":[92,96]}]}]}]} + diff --git a/github/tests/Search.py b/github/tests/Search.py index b06d1602..b5bd9b64 100644 --- a/github/tests/Search.py +++ b/github/tests/Search.py @@ -78,6 +78,10 @@ class Search(Framework.TestCase): else: self.assertEqual(files[0].decoded_content[:30], "https\nGET\napi.github.com\nNone\n") + def testSearchHighlightingCode(self): + files = self.g.search_code("toto", sort="indexed", order="asc", user="jacquev6", highlight=True) + self.assertTrue(files[0].text_matches) + def testUrlquotingOfQualifiers(self): # Example taken from #236 issues = self.g.search_issues("repo:saltstack/salt-api type:Issues", updated=">2014-03-04T18:28:11Z")