Maximiliano Bertacchini has proposed merging
lp:~maxiberta/launchpad/sitesearch-cleanup-1 into lp:launchpad.
Commit message:
Assorted sitesearch fixes and improvements.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~maxiberta/launchpad/sitesearch-cleanup-1/+merge/343131
Assorted sitesearch fixes and improvements.
- Rename BingSearchService._parse_bing_response() and
GoogleSearchService._parse_google_search_protocol() as
._parse_search_response().
- Move config.{bing,google}.url_rewrite_exceptions into config.sitesearch.
- Fix wrong content type of bingtestservice responses.
- Make googletestservice.py script executable.
--
Your team Launchpad code reviewers is requested to review the proposed merge of
lp:~maxiberta/launchpad/sitesearch-cleanup-1 into lp:launchpad.
=== modified file 'lib/lp/services/config/schema-lazr.conf'
--- lib/lp/services/config/schema-lazr.conf 2018-03-26 18:59:34 +
+++ lib/lp/services/config/schema-lazr.conf 2018-04-12 21:30:28 +
@@ -788,6 +788,7 @@
# datatype: string, a url to a host
site: http://www.google.com/cse
+[sitesearch]
# url_rewrite_exceptions is a list of launchpad.net domains that must
# not be rewritten.
# datatype: string of space separated domains
@@ -824,12 +825,6 @@
# datatype: string
custom_config_id:
-# url_rewrite_exceptions is a list of launchpad.net domains that must
-# not be rewritten.
-# datatype: string of space separated domains
-# Example: help.launchpad.net login.launchpad.net
-url_rewrite_exceptions: help.launchpad.net
-
[gpghandler]
# Should we allow uploading keys to the keyserver?
# datatype: boolean
=== modified file 'lib/lp/services/sitesearch/__init__.py'
--- lib/lp/services/sitesearch/__init__.py 2018-04-10 16:15:17 +
+++ lib/lp/services/sitesearch/__init__.py 2018-04-12 21:30:28 +
@@ -53,9 +53,9 @@
def url_rewrite_exceptions(self):
"""A list of launchpad.net URLs that must not be rewritten.
-Configured in config.google.url_rewrite_exceptions.
+Configured in config.sitesearch.url_rewrite_exceptions.
"""
-return config.google.url_rewrite_exceptions.split()
+return config.sitesearch.url_rewrite_exceptions.split()
@property
def url_rewrite_scheme(self):
@@ -221,7 +221,7 @@
"The response errored: %s" % str(error))
finally:
action.finish()
-page_matches = self._parse_google_search_protocol(response.content)
+page_matches = self._parse_search_response(response.content)
return page_matches
def _checkParameter(self, name, value, is_int=False):
@@ -272,7 +272,7 @@
"""
return self._getElementsByAttributeValue(doc, path, name, value)[0]
-def _parse_google_search_protocol(self, gsp_xml):
+def _parse_search_response(self, gsp_xml):
"""Return a `PageMatches` object.
:param gsp_xml: A string that should be Google Search Protocol
@@ -397,7 +397,7 @@
"The response errored: %s" % str(error))
finally:
action.finish()
-page_matches = self._parse_bing_response(response.content, start)
+page_matches = self._parse_search_response(response.content, start)
return page_matches
def _checkParameter(self, name, value, is_int=False):
@@ -430,7 +430,7 @@
'Ocp-Apim-Subscription-Key': self.subscription_key,
}
-def _parse_bing_response(self, bing_json, start=0):
+def _parse_search_response(self, bing_json, start=0):
"""Return a `PageMatches` object.
:param bing_json: A string containing Bing Custom Search API v7 JSON.
=== modified file 'lib/lp/services/sitesearch/bingtestservice.py'
--- lib/lp/services/sitesearch/bingtestservice.py 2018-03-28 21:28:12 +
+++ lib/lp/services/sitesearch/bingtestservice.py 2018-04-12 21:30:28 +
@@ -8,6 +8,10 @@
when given certain user-configurable URLs.
"""
+from __future__ import absolute_import, print_function, unicode_literals
+
+__metaclass__ = type
+
import logging
import os
@@ -27,7 +31,7 @@
class BingRequestHandler(testservice.RequestHandler):
-default_content_type = 'text/xml; charset=UTF-8'
+default_content_type = 'application/json; charset=UTF-8'
log = log
mapfile = config.bing_test_service.mapfile
content_dir = config.bing_test_service.canned_response_directory
=== modified file 'lib/lp/services/sitesearch/doc/bing-searchservice.txt'
--- lib/lp/services/sitesearch/doc/bing-searchservice.txt 2018-04-10 16:15:17 +
+++ lib/lp/services/sitesearch/doc/bing-searchservice.txt 2018-04-12 21:30:28 +
@@ -72,7 +72,7 @@
of returned results.
The first search for 'bugs' returned a subset of items in the
-ISearchResult. There are 25 total items, but the results contains the
+ISearchResult. There are 25 total items, but the results contain the
first 20 matches (because they