Skip to content

Commit 71aa55a

Browse files
committed
More clean-up and fixed overlooked attribute value URL determination.
1 parent 7eb741d commit 71aa55a

File tree

2 files changed

+38
-32
lines changed

2 files changed

+38
-32
lines changed

ncldDump/ncldDump.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,9 @@ def resolveValue(name, value, aliasDict):
273273
Determine if the value associated with the name has an entry in the alias
274274
dictionary. If it does, build a URL and return it.
275275
276-
name [in] A name to attempt to resolve into a hot-link string.
277-
value [in] A value to attempt to resolve into a hot-link string.
276+
name [in] A name associated with the value to attempt to resolve into
277+
a URL.
278+
value [in] A value to attempt to resolve into a URL.
278279
aliasDict [in] A dictionary of URI patterns keyed by the elements they
279280
replace.
280281
returns A URL, or None if there was no resolution.
@@ -285,18 +286,23 @@ def resolveValue(name, value, aliasDict):
285286
result = None
286287

287288
# If the name exists in the alias dictionary, and if the value exists in
288-
# the sub-dictionary for the name, create a hot-link string using the
289-
# pattern for the value. A wildcard (*) for a value key in the dictionary
290-
# matches any value.
289+
# the sub-dictionary for the name, create a URL using the pattern for the
290+
# value. A wildcard (*) for a value key in the dictionary matches any
291+
# value.
291292
#
292293
if name in aliasDict['values']:
293294
subDict = aliasDict['values'][name]
294295

296+
pattern = None
297+
295298
if value in subDict:
296299
pattern = subDict[value]
297-
298-
result = makeURL(value, pattern)
300+
elif '*' in subDict:
301+
pattern = subDict['*']
299302

303+
if pattern is not None:
304+
result = makeURL(value, pattern)
305+
300306
# Return the resolved name if one was found.
301307
#
302308
return result

ncldDump/ncldDump_template.html

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<li>netcdf {{ filePath|e }} {
2222
<ul>
2323
{%- if dimensions is defined %}
24-
<li>dimensions: //<a href="#dimensions_list" class="btn btn-default btn-xs" data-toggle="collapse">&darr;</a>
24+
<li>dimensions: // <a href="#dimensions_list" class="btn btn-default btn-xs" data-toggle="collapse">&darr;</a>
2525
<ul class="collapse in" id="dimensions_list">
2626
{%- for dimension in dimensions %}
2727
<li>{{ dimension.name|e }}&nbsp;=&nbsp;{{ dimension.value|e }} ;
@@ -32,23 +32,23 @@
3232
</li>
3333
{%- endif %}
3434
{%- if variables is defined %}
35-
<li>variables: //<a href="#variables_list" class="btn btn-default btn-xs" data-toggle="collapse">&darr;</a>
35+
<li>variables: // <a href="#variables_list" class="btn btn-default btn-xs" data-toggle="collapse">&darr;</a>
3636
<ul class="collapse in" id="variables_list">
3737
{%- for variable in variables %}
38-
<li id="variable_{{ variable.name }}">{{ variable.type|e }}&nbsp;
38+
<li id="variable_{{ variable.name }}">{{ variable.type|e }}&nbsp;
3939
{%- if variable.url is defined -%}
4040
<a href="{{ variable.url }}" target="_blank">{{ variable.name }}</a>
4141
{%- else -%}
4242
{{ variable.name }}
4343
{%- endif -%}
4444
{%- if variable.dimensions is defined -%}
4545
({{ variable.dimensions|join(', ')|e }})
46-
{%- endif -%}&nbsp;; //
47-
<a href="#variable_{{ variable.name }}_attrs" class="btn btn-default btn-xs" data-toggle="collapse">&darr;</a>
46+
{%- endif -%}
47+
&nbsp;; // <a href="#variable_{{ variable.name }}_attrs" class="btn btn-default btn-xs" data-toggle="collapse">&darr;</a>
4848
{%- if variable.attributes is defined %}
49-
<ul class="collapse in" id="variable_{{ variable.name }}_attrs">
49+
<ul class="collapse in" id="variable_{{ variable.name }}_attrs">
5050
{%- for attribute in variable.attributes %}
51-
<li>{{ variable.name }}:
51+
<li>{{ variable.name }}:
5252
{%- if attribute.url is defined -%}
5353
<a href="{{ attribute.url }}" target="_blank">{{ attribute.name }}</a>
5454
{%- else -%}
@@ -68,7 +68,7 @@
6868
{%- endif -%}
6969
{%- endfor -%}
7070
&nbsp;;
71-
</li>
71+
</li>
7272
{%- endfor %}
7373
</ul>
7474
{% endif -%}
@@ -83,25 +83,25 @@
8383
<ul class="collapse in" id="attribute_list">
8484
{%- for attribute in attributes %}
8585
<li>:
86-
{%- if attribute.url is defined -%}
87-
<a href="{{ attribute.url }}" target="_blank">{{ attribute.name }}</a>
86+
{%- if attribute.url is defined -%}
87+
<a href="{{ attribute.url }}" target="_blank">{{ attribute.name }}</a>
88+
{%- else -%}
89+
{{ attribute.name }}
90+
{%- endif -%}
91+
&nbsp;=
92+
{%- for value in attribute.value -%}
93+
&nbsp;
94+
{%- if value.url is defined -%}
95+
<a href="{{ value.url }}" target="_blank">{{ value.element }}</a>
8896
{%- else -%}
89-
{{ attribute.name }}
97+
{{ value.element }}
9098
{%- endif -%}
91-
&nbsp;=
92-
{%- for value in attribute.value -%}
93-
&nbsp;
94-
{%- if value.url is defined -%}
95-
<a href="{{ value.url }}" target="_blank">{{ value.element }}</a>
96-
{%- else -%}
97-
{{ value.element }}
98-
{%- endif -%}
99-
{{ attribute.type }}
100-
{%- if not loop.last -%}
101-
,
102-
{%- endif -%}
103-
{%- endfor -%}
104-
&nbsp;;
99+
{{ attribute.type }}
100+
{%- if not loop.last -%}
101+
,
102+
{%- endif -%}
103+
{%- endfor -%}
104+
&nbsp;;
105105
</li>
106106
{%- endfor %}
107107
</ul>

0 commit comments

Comments
 (0)