-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add registry.py from Nodesoftware - gonna need that soon
- Loading branch information
Showing
1 changed file
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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() |