From 891804b5082bcab7d1a58206a95bb4fb396daff7 Mon Sep 17 00:00:00 2001 From: "Adam Ginsburg (keflavich)" Date: Mon, 26 Oct 2015 16:00:50 +0100 Subject: [PATCH 1/3] NASA ADS was doing some bad things w.r.t. unicode. It doesn't have local tests. I've upgraded it a little, but more tests are very much needed! --- astroquery/nasa_ads/core.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/astroquery/nasa_ads/core.py b/astroquery/nasa_ads/core.py index 744f9127f0..916be56bde 100644 --- a/astroquery/nasa_ads/core.py +++ b/astroquery/nasa_ads/core.py @@ -34,14 +34,20 @@ class ADSClass(BaseQuery): def __init__(self, *args): """ set some parameters """ - pass + super(ADSClass, self).__init__() @class_or_instance - def query_simple(self, query_string, get_query_payload=False, get_raw_response=False): + def query_simple(self, query_string, get_query_payload=False, + get_raw_response=False, cache=True): + """ + Basic query. Uses a string and the ADS generic query. + """ self.query_string = query_string request_payload = self._args_to_payload(query_string) - response = commons.send_request(self.QUERY_SIMPLE_URL, request_payload, self.TIMEOUT) + response = self._request(method='POST', url=self.QUERY_SIMPLE_URL, + data=request_payload, timeout=self.TIMEOUT, + cache=cache) # primarily for debug purposes, but also useful if you want to send # someone a URL linking directly to the data @@ -50,12 +56,15 @@ def query_simple(self, query_string, get_query_payload=False, get_raw_response=F if get_raw_response: return response # parse the XML response into AstroPy Table - resulttable = self._parse_response(response.encode(results.encoding).decode('utf-8')) + resulttable = self._parse_response(response) return resulttable def _parse_response(self, response): - xmlrepr = minidom.parseString(response.text) + + encoded_content = response.text.encode(response.encoding) + + xmlrepr = minidom.parseString(encoded_content) # Check if there are any results! # get the list of hits From fcadc76ec6092a59feadd6e82b5986255c44a0ce Mon Sep 17 00:00:00 2001 From: "Adam Ginsburg (keflavich)" Date: Mon, 26 Oct 2015 16:01:53 +0100 Subject: [PATCH 2/3] remove unnecessary query_string attribute --- astroquery/nasa_ads/core.py | 1 - 1 file changed, 1 deletion(-) diff --git a/astroquery/nasa_ads/core.py b/astroquery/nasa_ads/core.py index 916be56bde..a03b09ca71 100644 --- a/astroquery/nasa_ads/core.py +++ b/astroquery/nasa_ads/core.py @@ -42,7 +42,6 @@ def query_simple(self, query_string, get_query_payload=False, """ Basic query. Uses a string and the ADS generic query. """ - self.query_string = query_string request_payload = self._args_to_payload(query_string) response = self._request(method='POST', url=self.QUERY_SIMPLE_URL, From 1bf0233f7f9836e272eb302f545470d5ac99fad1 Mon Sep 17 00:00:00 2001 From: "Adam Ginsburg (keflavich)" Date: Mon, 26 Oct 2015 16:03:16 +0100 Subject: [PATCH 3/3] add changelog entry --- CHANGES | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 0c5c00eb72..3ad957837a 100644 --- a/CHANGES +++ b/CHANGES @@ -1,7 +1,7 @@ 0.3.1.dev --------- -- None yet +- Fix NASA ADS, which had an internal syntax error (#602) 0.3.0 (2015-10-26) ------------------