source: TI12-security/trunk/python/Tests/VocabServer/getDefinitionGCMD.py @ 1566

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/python/Tests/VocabServer/getDefinitionGCMD.py@4692
Revision 1566, 1.1 KB checked in by lawrence, 14 years ago (diff)

Toy code to play with the vocab server ... using Phil's base ...

Line 
1#!/bin/env python
2#
3# First cut at getting GCMD definitions for NDG discovery gateway
4#
5# Import the client proxy object
6from VocabServerAPI_dlService_client import * 
7import xml.etree.ElementTree as ET
8import sys
9
10
11# Instantiate a client proxy object
12loc = VocabServerAPI_dlServiceLocator()
13vocabSrv = loc.getVocabServerAPI_dl()
14
15try:
16    #import pdb;pdb.set_trace()
17    whatLists = vocabSrv.whatListsCat()
18    print 'Lists in Catalogue at Vocab Server:\n'
19    for elem in whatLists:
20        x=ET.fromstring(elem)
21        print x.find('entryTerm').text
22except Exception, e:
23    print "Failed whatLists: ", e
24
25try:
26    #this works: gives all members of GCMD vocabulary
27    #res=vocabSrv.getList('P041','','')
28    #for i in res:
29    #    x=ET.fromstring(i)
30    #    print x.find('entryTerm').text
31   
32    # this is just a toy example
33    term='EARTH SCIENCE > Oceans > Ocean Waves > Wave Height'
34    r=vocabSrv.verifyTerm('P041',term,'')
35    print r
36    res=ET.fromstring(vocabSrv.getList('P041',r[0],'')[0])
37    print '{{',term,'}} is defined as {{',res.find('entryTermDef').text,'}}'
38except Exception, e:
39    print "Failed getList: ", e
Note: See TracBrowser for help on using the repository browser.