-
Notifications
You must be signed in to change notification settings - Fork 3
/
registry.py
executable file
·60 lines (47 loc) · 1.59 KB
/
registry.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
routines for querying the registry
"""
REL_REG='http://registry.vamdc.eu/vamdc_registry/services/RegistryQueryv1_0'
DEV_REG='http://casx019-zone1.ast.cam.ac.uk/registry/services/RegistryQueryv1_0'
REGURL=DEV_REG
WSDL=REGURL+'?wsdl'
# this is a copy of the URL above but with
# schema locations fixed:
WSDL = 'http://tmy.se/t/devreg_wsdl.xml'
from suds.client import Client
from suds.xsd.doctor import Doctor
class RegistryDoctor(Doctor):
TNS = 'http://www.ivoa.net/wsdl/RegistrySearch/v1.0'
def examine(self, node):
tns = node.get('targetNamespace')
# find a specific schema
if tns != self.TNS:
return
for e in node.getChildren('element'):
# find our response element
if e.get('name') != 'XQuerySearchResponse':
continue
# fix the <xs:any/> by adding maxOccurs
any = e.childAtPath('complexType/sequence/any')
any.set('maxOccurs', 'unbounded')
break
def getNodeList():
d = RegistryDoctor()
client = Client(WSDL,doctor=d)
qr="""declare namespace ri='http://www.ivoa.net/xml/RegistryInterface/v1.0';
for $x in //ri:Resource
where $x/capability[@standardID='ivo://vamdc/std/VAMDC-TAP']
and $x/@status='active'
return ($x/title, $x/capability[@standardID='ivo://vamdc/std/VAMDC-TAP']/interface/accessURL)"""
v=client.service.XQuerySearch(qr)
nameurls=[]
while v:
nameurls.append({\
'name':v.pop(1),
'url':v.pop(0)['value'],
})
return nameurls
if __name__ == '__main__':
print getNodeList()