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) ------------------ diff --git a/astroquery/nasa_ads/core.py b/astroquery/nasa_ads/core.py index 744f9127f0..a03b09ca71 100644 --- a/astroquery/nasa_ads/core.py +++ b/astroquery/nasa_ads/core.py @@ -34,14 +34,19 @@ 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): - self.query_string = query_string + 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. + """ 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 +55,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