-
Notifications
You must be signed in to change notification settings - Fork 0
/
prefixes.py
49 lines (39 loc) · 1.6 KB
/
prefixes.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
# Python module to hold the master references for Metadata Translation prefixes
import StringIO
class Prefixes(object):
prefixd = {
'iso19135' : 'https://reference.metoffice.gov.uk/data/wmo/def/iso19135/',
'metExtra' : 'https://reference.metoffice.gov.uk/data/wmo/def/met/',
'rdfs' : 'https://www.w3.org/2000/01/rdf-schema#',
'rdf' : 'https://www.w3.org/1999/02/22-rdf-syntax-ns#',
'skos' : 'https://www.w3.org/2004/02/skos/core#',
'mos' : 'https://reference.metoffice.gov.uk/data/stash/',
'mof' : 'https://reference.metoffice.gov.uk/data/fieldcode/',
'mon' : 'https://reference.metoffice.gov.uk/data/none/',
'fcode' : 'https://www-hc/~umdoc/pp_package_ibm_docs/fcodes/',
'cf' : 'https://cf-pcmdi.llnl.gov/documents/',
}
@property
def sparql(self):
ios = StringIO.StringIO()
for key, value in sorted(self.prefixd.items()):
ios.write('PREFIX %s: <%s>\n' % (key, value))
ios.write('\n')
return ios.getvalue()
@property
def turtle(self):
ios = StringIO.StringIO()
for key, value in sorted(self.prefixd.items()):
ios.write('@prefix %s: <%s> .\n' % (key, value))
ios.write('\n')
return ios.getvalue()
@property
def rdf(self):
ios = StringIO.StringIO()
for key, value in sorted(self.prefixd.items()):
ios.write('xmlns:%s="%s"\n' % (key, value))
ios.write('\n')
return ios.getvalue()
@property
def irilist(self):
return sorted(self.prefixd.values())