-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget.skos.nerc.cf.vocab.py
44 lines (33 loc) · 1.05 KB
/
get.skos.nerc.cf.vocab.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
# skos dictionary get
import urlparse
import urllib2
from xml.etree import ElementTree as ET
import xml.dom.minidom
url = "http://vocab.nerc.ac.uk/collection/P07/current/"
# <gmd:keyword>
# <sdn:SDN_ParameterDiscoveryCode codeSpace="SeaDataNet" codeListValue="ATVS"
# codeList="http://vocab.nerc.ac.uk/isoCodelists/sdnCodelists/cdicsrCodeList.xml#SDN_ParameterDiscoveryCode">Atmospheric visibility and transparency</sdn:SDN_ParameterDiscoveryCode>
# </gmd:keyword>
# http://vocab.nerc.ac.uk/collection/P07/current/#air_temperature
#class Vocab(self):
req = urllib2.urlopen(url)
catXml = req.read()
vocab = []
# print xml...
#print catXml
# xml formater in lxml
tree = ET.fromstring(catXml)
#xmlf = xml.dom.minidom.parseString(catXml)
#pretty_xml_as_string = xmlf.toprettyxml()
#print pretty_xml_as_string
for v in tree.getiterator():
if "prefLabel" in v.tag:
#print v.text
vocab.append(v.text)
print vocab
# <gco:CharacterString>Climate and Forecast Standard Names</gco:CharacterString>
def check(term):
if term in vocab:
return True
else:
return False