Skip to content

Commit eeb0d07

Browse files
authored
Merge pull request #2423 from bsipocz/oac_fix_parsing
BUG: Fix OAC parsing issue
2 parents d254369 + e8acce3 commit eeb0d07

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

CHANGES.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ linelists.cdms
4343
- Fix issues with the line name parser and the line data parser; the original
4444
implementation was incomplete and upstream was not fully documented. [#2385, #2411]
4545

46+
oac
47+
^^^
48+
49+
- Fix bug in parsing events that contain html tags (e.g. in their alias
50+
field). [#2423]
51+
52+
4653
Infrastructure, Utility and Other Changes and Additions
4754
-------------------------------------------------------
4855

astroquery/oac/core.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import json
1414
import csv
15+
import re
1516

1617
import astropy.units as u
1718
from astropy.table import Column, Table
@@ -435,7 +436,12 @@ def _args_to_payload(self, event, quantity,
435436

436437
def _format_output(self, raw_output):
437438
if self.FORMAT == 'csv':
438-
split_output = raw_output.splitlines()
439+
440+
fixed_raw_output = re.sub('<[^<]+?>', '', raw_output)
441+
split_output = fixed_raw_output.splitlines()
442+
443+
# Remove any HTML tags
444+
439445
columns = list(csv.reader([split_output[0]], delimiter=',',
440446
quotechar='"'))[0]
441447
rows = split_output[1:]

astroquery/oac/tests/test_oac_remote.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,25 +59,27 @@ def test_query_region_box_json(self):
5959
data_format='json')
6060
assert isinstance(phot, dict)
6161

62-
@pytest.mark.xfail(reason="Upstream API issue. See #1130")
6362
def test_get_photometry(self):
6463
phot = OAC.get_photometry(event="SN2014J")
6564
assert isinstance(phot, Table)
65+
assert len(phot) > 0
6666

6767
def test_get_photometry_b(self):
6868
phot = OAC.get_photometry(event="SN2014J")
6969
assert isinstance(phot, Table)
70+
assert len(phot) > 0
7071

71-
@pytest.mark.xfail(reason="Upstream API issue. See #1130")
7272
def test_get_single_spectrum(self):
7373
spec = OAC.get_single_spectrum(event="SN2014J",
7474
time=self.test_time)
7575
assert isinstance(spec, Table)
76+
assert len(spec) > 0
7677

7778
def test_get_single_spectrum_b(self):
7879
test_time = 56680
7980
spec = OAC.get_single_spectrum(event="SN2014J", time=test_time)
8081
assert isinstance(spec, Table)
82+
assert len(spec) > 0
8183

8284
def test_get_spectra(self):
8385
spec = OAC.get_spectra(event="SN2014J")

0 commit comments

Comments
 (0)