Skip to content

Commit 899eb89

Browse files
committed
Added sensitivity to context__name elements in the value parts of attributes.
1 parent e640587 commit 899eb89

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

ncldDump/aliases.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
22
"contexts" :
33
{
4+
"bald" : "http://binary-array-ld.net/latest/{}",
5+
"rdf" : "http://www.w3.org/1999/02/22-rdf-syntax-ns#{}"
46
},
57
"names" :
68
{
@@ -99,7 +101,8 @@
99101
"units" : "http://cfconventions.org/cf-conventions/v1.6.0/cf-conventions.html#units",
100102
"valid_max" : "http://www.unidata.ucar.edu/netcdf/docs/netcdf.html#Attribute-Conventions",
101103
"valid_min" : "http://www.unidata.ucar.edu/netcdf/docs/netcdf.html#Attribute-Conventions",
102-
"valid_range" : "http://www.unidata.ucar.edu/netcdf/docs/netcdf.html#Attribute-Conventions"
104+
"valid_range" : "http://www.unidata.ucar.edu/netcdf/docs/netcdf.html#Attribute-Conventions",
105+
"SDN_ParameterDiscoveryCode" : "http://vocab.nerc.ac.uk/isoCodelists/sdnCodelists/cdicsrCodeList.xml#{}"
103106
},
104107
"values" :
105108
{
@@ -131,6 +134,10 @@
131134
"standard_name" :
132135
{
133136
"*" : "http://mmisw.org/ont/cf/parameter/{}"
137+
},
138+
"SDN_ParameterDiscoveryCode" :
139+
{
140+
"BactTaxaAbundSed" : "http://vocab.nerc.ac.uk/collection/P02/current/BAUC/"
134141
}
135142
}
136143
}

ncldDump/ncldDump.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ def makeURL(word, pattern):
197197
'''
198198
Create a URL from the word and pattern.
199199
200-
word [in] The word to build the hot-link around.
200+
word [in] The word to build the URL around.
201201
pattern [in] The URL pattern to reference.
202202
returns A URL.
203203
'''
@@ -218,7 +218,7 @@ def resolveName(name, aliasDict):
218218
If not, attempt to resolve the name into a URL using the names
219219
part of the alias dictionary.
220220
221-
name [in] A name to attempt to resolve into a hot-link string.
221+
name [in] A name to attempt to resolve into a URL string.
222222
aliasDict [in] A dictionary of URI patterns keyed by the elements they
223223
replace.
224224
returns A URL, or None if there was no resolution.
@@ -243,7 +243,7 @@ def resolveName(name, aliasDict):
243243
contextPart = nameParts[0]
244244
namePart = nameParts[1]
245245

246-
# If the context exists in the alias dictionary, create a hot-link
246+
# If the context exists in the alias dictionary, create a URL
247247
# string using the pattern for the context and the name part.
248248
#
249249
if contextPart in aliasDict['contexts']:
@@ -253,7 +253,7 @@ def resolveName(name, aliasDict):
253253

254254
break
255255

256-
# If the name exists in the alias dictionary, create a hot-link string
256+
# If the name exists in the alias dictionary, create a URL string
257257
# using the pattern for the name.
258258
#
259259
if name in aliasDict['names']:
@@ -285,12 +285,21 @@ def resolveValue(name, value, aliasDict):
285285
#
286286
result = None
287287

288+
# Attempt to split the value on '__'.
289+
#
290+
valueParts = value.split('__')
291+
292+
# If there is a context part, resolve the value as a name.
293+
#
294+
if 2 == len(valueParts):
295+
result = resolveName(value, aliasDict)
296+
288297
# If the name exists in the alias dictionary, and if the value exists in
289298
# the sub-dictionary for the name, create a URL using the pattern for the
290299
# value. A wildcard (*) for a value key in the dictionary matches any
291300
# value.
292301
#
293-
if name in aliasDict['values']:
302+
elif name in aliasDict['values']:
294303
subDict = aliasDict['values'][name]
295304

296305
pattern = None

0 commit comments

Comments
 (0)