Skip to content

Commit

Permalink
Merge pull request #2423 from bsipocz/oac_fix_parsing
Browse files Browse the repository at this point in the history
BUG: Fix OAC parsing issue
  • Loading branch information
bsipocz authored Jun 3, 2022
2 parents d254369 + e8acce3 commit eeb0d07
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
7 changes: 7 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
-------------------------------------------------------

Expand Down
8 changes: 7 additions & 1 deletion astroquery/oac/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import json
import csv
import re

import astropy.units as u
from astropy.table import Column, Table
Expand Down Expand Up @@ -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:]
Expand Down
6 changes: 4 additions & 2 deletions astroquery/oac/tests/test_oac_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit eeb0d07

Please sign in to comment.