Skip to content

Commit

Permalink
RegTAP search: flag for including aux capabilities
Browse files Browse the repository at this point in the history
per astropy#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.
  • Loading branch information
tsdower authored Oct 30, 2020
1 parent 6b00f93 commit f599ed6
Showing 1 changed file with 35 additions and 13 deletions.
48 changes: 35 additions & 13 deletions pyvo/registry/regtap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
-------
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit f599ed6

Please sign in to comment.