Skip to content

Commit 8a0577d

Browse files
committed
Replace the pedantic option for VOTable parsing
The `pedantic` option for `parse()` and `parse_single_table()` functions in `astropy.io.votable` has been deprecated since astropy/astropy#12129 in favour of the `verify` option. This commit replaces the uses of the deprecated option in `astroquery`.
1 parent 41249c4 commit 8a0577d

File tree

11 files changed

+17
-15
lines changed

11 files changed

+17
-15
lines changed

astroquery/casda/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ def _parse_datalink_for_service_and_id(self, response, service_name):
262262
"""
263263
data = BytesIO(response.content)
264264

265-
votable = parse(data, pedantic=False)
265+
votable = parse(data, verify='warn')
266266
results = next(resource for resource in votable.resources if
267267
resource.type == "results")
268268
if results is None:

astroquery/ipac/irsa/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ def _parse_result(self, response, verbose=False):
336336
# Read it in using the astropy VO table reader
337337
try:
338338
first_table = votable.parse(BytesIO(response.content),
339-
pedantic=False).get_first_table()
339+
verify='warn').get_first_table()
340340
except Exception as ex:
341341
self.response = response
342342
self.table_parse_error = ex

astroquery/ipac/ned/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ def _parse_result(self, response, verbose=False):
681681
commons.suppress_vo_warnings()
682682
try:
683683
tf = BytesIO(response.content)
684-
first_table = votable.parse(tf, pedantic=False).get_first_table()
684+
first_table = votable.parse(tf, verify='warn').get_first_table()
685685
table = first_table.to_table(use_names_over_ids=True)
686686
return table
687687
except Exception as ex:

astroquery/nrao/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ def _parse_votable_result(self, response, verbose=False):
437437
try:
438438
tf = BytesIO(new_content.encode())
439439
first_table = votable.parse(
440-
tf, pedantic=False,
440+
tf, verify='warn',
441441
datatype_mapping=datatype_mapping).get_first_table()
442442
try:
443443
table = first_table.to_table(use_names_over_ids=True)

astroquery/simbad/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def __init__(self, txt, verbose=False, pedantic=False):
189189
def table(self):
190190
if self.__table is None:
191191
self.bytes = BytesIO(self.data.encode('utf8'))
192-
tbl = votable.parse_single_table(self.bytes, pedantic=False)
192+
tbl = votable.parse_single_table(self.bytes, verify='warn')
193193
self.__table = tbl.to_table()
194194
self.__table.convert_bytestring_to_unicode()
195195
return self.__table

astroquery/utils/commons.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,5 +457,5 @@ def parse_votable(content):
457457
"""
458458
Parse a votable in string format
459459
"""
460-
tables = votable.parse(BytesIO(content), pedantic=False)
460+
tables = votable.parse(BytesIO(content), verify='warn')
461461
return tables

astroquery/vizier/core.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -761,15 +761,15 @@ def parse_vizier_votable(data, verbose=False, invalid='warn',
761761
tf = BytesIO(data)
762762

763763
if invalid == 'mask':
764-
vo_tree = votable.parse(tf, pedantic=False, invalid='mask')
764+
vo_tree = votable.parse(tf, verify='warn', invalid='mask')
765765
elif invalid == 'warn':
766766
try:
767-
vo_tree = votable.parse(tf, pedantic=False, invalid='exception')
767+
vo_tree = votable.parse(tf, verify='warn', invalid='exception')
768768
except Exception as ex:
769769
warnings.warn("VOTABLE parsing raised exception: {0}".format(ex))
770-
vo_tree = votable.parse(tf, pedantic=False, invalid='mask')
770+
vo_tree = votable.parse(tf, verify='warn', invalid='mask')
771771
elif invalid == 'exception':
772-
vo_tree = votable.parse(tf, pedantic=False, invalid='exception')
772+
vo_tree = votable.parse(tf, verify='warn', invalid='exception')
773773
else:
774774
raise ValueError("Invalid keyword for 'invalid'. "
775775
"Must be exception, mask, or warn")

astroquery/vo_conesearch/core.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,9 @@ def _parse_result(self, response, url, pars={}, verbose=False):
180180
parsed_url = url + '&'.join(query)
181181

182182
# Parse the result
183+
pedantic = 'exception' if conf.pedantic else 'warn'
183184
tab = table.parse(BytesIO(response.content), filename=parsed_url,
184-
pedantic=conf.pedantic)
185+
verify=pedantic)
185186
try:
186187
result = vo_tab_parse(tab, url, pars)
187188
except VOSError as exc:

astroquery/vo_conesearch/validator/validate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ def _do_validation(args):
301301
with warnings.catch_warnings(record=True) as warning_lines:
302302
try:
303303
vo_tab_parse(votable.table.parse(
304-
r.get_vo_xml_path(), pedantic=False), r.url, {})
304+
r.get_vo_xml_path(), verify='warn'), r.url, {})
305305
except (E19, IndexError, VOSError) as e: # pragma: no cover
306306
lines.append(str(e))
307307
nexceptions += 1

astroquery/vo_conesearch/vos_catalog.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ def from_registry(cls, registry_url, timeout=60, **kwargs):
566566
# Download registry as VO table
567567
with data_conf.set_temp('remote_timeout', timeout):
568568
with get_readable_fileobj(registry_url, **kwargs) as fd:
569-
tab_all = parse_single_table(fd, pedantic=False)
569+
tab_all = parse_single_table(fd, verify='warn')
570570

571571
# Registry must have these fields
572572
compulsory_fields = ['res_title', 'access_url']
@@ -728,7 +728,8 @@ def _vo_service_request(url, pedantic, kwargs, cache=True, verbose=False):
728728
parsed_url = url + '&'.join(query)
729729
with get_readable_fileobj(parsed_url, encoding='binary', cache=cache,
730730
show_progress=verbose) as req:
731-
tab = table.parse(req, filename=parsed_url, pedantic=pedantic)
731+
pedantic = 'exception' if pedantic else 'warn'
732+
tab = table.parse(req, filename=parsed_url, verify=pedantic)
732733

733734
return vo_tab_parse(tab, url, kwargs)
734735

0 commit comments

Comments
 (0)