From f599ed6b87f38b0a68dbc5c0d39f1e2bfe9ee749 Mon Sep 17 00:00:00 2001 From: theresa dower Date: Fri, 30 Oct 2020 11:48:00 -0400 Subject: [PATCH] RegTAP search: flag for including aux capabilities per https://github.com/astropy/pyvo/issues/238 Proposed search flag includeaux : boolean Flag for whether to include auxiliary capabilities in results. This may result in duplicate capabilities being returned, especially if the servicetype is not specified. This came up in a NAVO notebook use case, not sure yet if it's exactly what we want. --- pyvo/registry/regtap.py | 48 ++++++++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/pyvo/registry/regtap.py b/pyvo/registry/regtap.py index 8a81faaf9..3bd6c0d0f 100644 --- a/pyvo/registry/regtap.py +++ b/pyvo/registry/regtap.py @@ -34,7 +34,7 @@ } -def search(keywords=None, servicetype=None, waveband=None, datamodel=None): +def search(keywords=None, servicetype=None, waveband=None, datamodel=None, includeaux=False): """ execute a simple query to the RegTAP registry. @@ -70,6 +70,10 @@ def search(keywords=None, servicetype=None, waveband=None, datamodel=None): See http://wiki.ivoa.net/twiki/bin/view/IVOA/IvoaDataModel for more informations about data models. + includeaux : boolean + Flag for whether to include auxiliary capabilities in results. + This may result in duplicate capabilities being returned, + especially if the servicetype is not specified. Returns ------- @@ -109,19 +113,37 @@ def _unions(): if servicetype: servicetype = _service_type_map.get(servicetype, servicetype) - - wheres.append("standard_id LIKE 'ivo://ivoa.net/std/{}'".format( - tap.escape(servicetype))) + if includeaux: + wheres.append(""" + (standard_id LIKE 'ivo://ivoa.net/std/%aux' OR + standard_id LIKE 'ivo://ivoa.net/std/{}') + """.format(tap.escape(servicetype))) + else: + wheres.append("standard_id LIKE 'ivo://ivoa.net/std/{}'".format( + tap.escape(servicetype))) else: - wheres.append(""" - standard_id IN ( - 'ivo://ivoa.net/std/conesearch', - 'ivo://ivoa.net/std/sia', - 'ivo://ivoa.net/std/ssa', - 'ivo://ivoa.net/std/slap', - 'ivo://ivoa.net/std/tap' - ) - """) + if includeaux: + wheres.append(""" + (standard_id LIKE 'ivo://ivoa.net/std/%aux' OR + standard_id IN ( + 'ivo://ivoa.net/std/conesearch', + 'ivo://ivoa.net/std/sia', + 'ivo://ivoa.net/std/ssa', + 'ivo://ivoa.net/std/slap', + 'ivo://ivoa.net/std/tap' + ) + ) + """) + else: + wheres.append(""" + standard_id IN ( + 'ivo://ivoa.net/std/conesearch', + 'ivo://ivoa.net/std/sia', + 'ivo://ivoa.net/std/ssa', + 'ivo://ivoa.net/std/slap', + 'ivo://ivoa.net/std/tap' + ) + """) if waveband: wheres.append("1 = ivo_hashlist_has(rr.resource.waveband, '{}')".format(