diff --git a/CHANGES.rst b/CHANGES.rst index 973cd1179a..5937e3ab65 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -43,6 +43,13 @@ linelists.cdms - Fix issues with the line name parser and the line data parser; the original implementation was incomplete and upstream was not fully documented. [#2385, #2411] +oac +^^^ + +- Fix bug in parsing events that contain html tags (e.g. in their alias + field). [#2423] + + Infrastructure, Utility and Other Changes and Additions ------------------------------------------------------- diff --git a/astroquery/oac/core.py b/astroquery/oac/core.py index 28148b4166..84286dd9dd 100644 --- a/astroquery/oac/core.py +++ b/astroquery/oac/core.py @@ -12,6 +12,7 @@ import json import csv +import re import astropy.units as u from astropy.table import Column, Table @@ -435,7 +436,12 @@ def _args_to_payload(self, event, quantity, def _format_output(self, raw_output): if self.FORMAT == 'csv': - split_output = raw_output.splitlines() + + fixed_raw_output = re.sub('<[^<]+?>', '', raw_output) + split_output = fixed_raw_output.splitlines() + + # Remove any HTML tags + columns = list(csv.reader([split_output[0]], delimiter=',', quotechar='"'))[0] rows = split_output[1:] diff --git a/astroquery/oac/tests/test_oac_remote.py b/astroquery/oac/tests/test_oac_remote.py index 3980547068..e14567900a 100644 --- a/astroquery/oac/tests/test_oac_remote.py +++ b/astroquery/oac/tests/test_oac_remote.py @@ -59,25 +59,27 @@ def test_query_region_box_json(self): data_format='json') assert isinstance(phot, dict) - @pytest.mark.xfail(reason="Upstream API issue. See #1130") def test_get_photometry(self): phot = OAC.get_photometry(event="SN2014J") assert isinstance(phot, Table) + assert len(phot) > 0 def test_get_photometry_b(self): phot = OAC.get_photometry(event="SN2014J") assert isinstance(phot, Table) + assert len(phot) > 0 - @pytest.mark.xfail(reason="Upstream API issue. See #1130") def test_get_single_spectrum(self): spec = OAC.get_single_spectrum(event="SN2014J", time=self.test_time) assert isinstance(spec, Table) + assert len(spec) > 0 def test_get_single_spectrum_b(self): test_time = 56680 spec = OAC.get_single_spectrum(event="SN2014J", time=test_time) assert isinstance(spec, Table) + assert len(spec) > 0 def test_get_spectra(self): spec = OAC.get_spectra(event="SN2014J")