Skip to content

Commit 49391ff

Browse files
authored
Merge pull request #84 from marqh/this
This
2 parents 48d1b71 + 17740b1 commit 49391ff

11 files changed

+413
-405
lines changed

lib/bald/__init__.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,16 +254,21 @@ def __getitem__(self, item):
254254
if not self.is_http_uri(item):
255255
raise ValueError('{} is not a HTTP URI.'.format(item))
256256
if item not in self.cache:
257+
# null response, as a fall back
258+
self.cache[item] = requests.models.Response()
257259
# now = time.time()
258260
try:
259261
# print('trying: {}'.format(item))
260262

261263
headers = {'Accept': 'application/rdf+xml'}
262264
self.cache[item] = requests.get(item, headers=headers, timeout=11)
263265
except Exception:
264-
# print('retrying: {}'.format(item))
265-
headers = {'Accept': 'text/html'}
266-
self.cache[item] = requests.get(item, headers=headers, timeout=11)
266+
try:
267+
# print('retrying: {}'.format(item))
268+
headers = {'Accept': 'text/html'}
269+
self.cache[item] = requests.get(item, headers=headers, timeout=11)
270+
except Exception:
271+
pass
267272

268273
# print('in {} seconds'.format(time.time() - then))
269274
return self.cache[item]
@@ -577,7 +582,7 @@ def rdfgraph(self):
577582
"""
578583
graph = rdflib.Graph()
579584
graph.bind('bald', 'http://binary-array-ld.net/latest/')
580-
graph.bind('ns1', self.baseuri + '/')
585+
graph.bind('this', self.baseuri + '/')
581586
for prefix_name in self.prefixes():
582587

583588
#strip the double underscore suffix

lib/bald/tests/integration/CDL/array_geo.cdl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ variables:
88
prefix_list:rdf__ = "http://www.w3.org/1999/02/22-rdf-syntax-ns#" ;
99
prefix_list:rdfs__ = "http://www.w3.org/2000/01/rdf-schema#" ;
1010
prefix_list:cf__ = "http://def.scitools.org.uk/CFTerms/" ;
11+
prefix_list:nc__ = "http://def.scitools.org.uk/NetCDF/" ;
1112
prefix_list:geo__ = "http://www.opengis.net/ont/geosparql#" ;
1213
prefix_list:nc__ = "http://def.scitools.org.uk/NetCDF/" ;
1314

lib/bald/tests/integration/CDL/array_multitypes.cdl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ variables:
88
prefix_list:rdf__ = "http://www.w3.org/1999/02/22-rdf-syntax-ns#" ;
99
prefix_list:rdfs__ = "http://www.w3.org/2000/01/rdf-schema#" ;
1010
prefix_list:cf__ = "http://def.scitools.org.uk/CFTerms/" ;
11+
prefix_list:nc__ = "http://def.scitools.org.uk/NetCDF/" ;
1112
prefix_list:geo__ = "http://www.opengis.net/ont/geosparql#" ;
1213
prefix_list:nc__ = "http://def.scitools.org.uk/NetCDF/" ;
1314

lib/bald/tests/integration/TTL/GEMS_CO2_Apr2006.ttl

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,32 @@
22
@prefix NetCDF: <http://def.scitools.org.uk/NetCDF/> .
33
@prefix bald: <http://binary-array-ld.net/latest/> .
44
@prefix cf_sname: <http://vocab.nerc.ac.uk/standard_name/> .
5-
@prefix ns1: <file://CDL/GEMS_CO2_Apr2006.cdl/> .
65
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
76
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
7+
@prefix this: <file://CDL/GEMS_CO2_Apr2006.cdl/> .
88
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
99
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
1010

1111
<file://CDL/GEMS_CO2_Apr2006.cdl> a bald:Container ;
12-
bald:contains ns1:co2,
13-
ns1:co2_latitude_ref,
14-
ns1:co2_levelist_ref,
15-
ns1:co2_time_ref,
16-
ns1:latitude,
17-
ns1:levelist,
18-
ns1:lnsp,
19-
ns1:lnsp_latitude_ref,
20-
ns1:lnsp_levelist_ref,
21-
ns1:lnsp_time_ref,
22-
ns1:longitude,
23-
ns1:time ;
12+
bald:contains this:co2,
13+
this:co2_latitude_ref,
14+
this:co2_levelist_ref,
15+
this:co2_time_ref,
16+
this:latitude,
17+
this:levelist,
18+
this:lnsp,
19+
this:lnsp_latitude_ref,
20+
this:lnsp_levelist_ref,
21+
this:lnsp_time_ref,
22+
this:longitude,
23+
this:time ;
2424
NetCDF:Conventions "CF-1.0" .
2525

26-
ns1:co2 a bald:Array ;
27-
bald:references ns1:co2_latitude_ref,
28-
ns1:co2_levelist_ref,
29-
ns1:co2_time_ref,
30-
ns1:longitude ;
26+
this:co2 a bald:Array ;
27+
bald:references this:co2_latitude_ref,
28+
this:co2_levelist_ref,
29+
this:co2_time_ref,
30+
this:longitude ;
3131
bald:shape "(1, 60, 181, 360)" ;
3232
CFTerms:missing_value "-32767" ;
3333
CFTerms:standard_name <http://vocab.nerc.ac.uk/standard_name/mass_fraction_of_carbon_dioxide_in_air/> ;
@@ -37,77 +37,77 @@ ns1:co2 a bald:Array ;
3737
NetCDF:scale_factor 0.000981685145029486 ;
3838
NetCDF:units "kg kg**-1" .
3939

40-
ns1:lnsp a bald:Array ;
41-
bald:references ns1:lnsp_latitude_ref,
42-
ns1:lnsp_levelist_ref,
43-
ns1:lnsp_time_ref,
44-
ns1:longitude ;
40+
this:lnsp a bald:Array ;
41+
bald:references this:lnsp_latitude_ref,
42+
this:lnsp_levelist_ref,
43+
this:lnsp_time_ref,
44+
this:longitude ;
4545
bald:shape "(1, 60, 181, 360)" ;
4646
CFTerms:missing_value "-32767" ;
4747
NetCDF:FillValue "-32767" ;
4848
NetCDF:add_offset 11.2087164280841 ;
4949
NetCDF:long_name "Logarithm of surface pressure" ;
5050
NetCDF:scale_factor 1.03952457840347e-05 .
5151

52-
ns1:co2_latitude_ref a bald:Reference,
52+
this:co2_latitude_ref a bald:Reference,
5353
bald:Subject ;
54-
bald:array ns1:latitude ;
54+
bald:array this:latitude ;
5555
bald:childBroadcast "(1, 1, 181, 1)" .
5656

57-
ns1:co2_levelist_ref a bald:Reference,
57+
this:co2_levelist_ref a bald:Reference,
5858
bald:Subject ;
59-
bald:array ns1:levelist ;
59+
bald:array this:levelist ;
6060
bald:childBroadcast "(1, 60, 1, 1)" .
6161

62-
ns1:co2_time_ref a bald:Reference,
62+
this:co2_time_ref a bald:Reference,
6363
bald:Subject ;
64-
bald:array ns1:time ;
64+
bald:array this:time ;
6565
bald:childBroadcast "(1, 1, 1, 1)" .
6666

67-
ns1:lnsp_latitude_ref a bald:Reference,
67+
this:lnsp_latitude_ref a bald:Reference,
6868
bald:Subject ;
69-
bald:array ns1:latitude ;
69+
bald:array this:latitude ;
7070
bald:childBroadcast "(1, 1, 181, 1)" .
7171

72-
ns1:lnsp_levelist_ref a bald:Reference,
72+
this:lnsp_levelist_ref a bald:Reference,
7373
bald:Subject ;
74-
bald:array ns1:levelist ;
74+
bald:array this:levelist ;
7575
bald:childBroadcast "(1, 60, 1, 1)" .
7676

77-
ns1:lnsp_time_ref a bald:Reference,
77+
this:lnsp_time_ref a bald:Reference,
7878
bald:Subject ;
79-
bald:array ns1:time ;
79+
bald:array this:time ;
8080
bald:childBroadcast "(1, 1, 1, 1)" .
8181

82-
ns1:latitude a bald:Array,
82+
this:latitude a bald:Array,
8383
bald:Reference ;
84-
bald:array ns1:latitude ;
84+
bald:array this:latitude ;
8585
bald:first_value 90.0 ;
8686
bald:last_value -90.0 ;
8787
bald:shape "(181,)" ;
8888
CFTerms:standard_name <http://vocab.nerc.ac.uk/standard_name/latitude/> ;
8989
NetCDF:units "degrees_north" .
9090

91-
ns1:levelist a bald:Array,
91+
this:levelist a bald:Array,
9292
bald:Reference ;
93-
bald:array ns1:levelist ;
93+
bald:array this:levelist ;
9494
bald:first_value 1 ;
9595
bald:last_value 60 ;
9696
bald:shape "(60,)" ;
9797
NetCDF:long_name "model_level_number" .
9898

99-
ns1:longitude a bald:Array,
99+
this:longitude a bald:Array,
100100
bald:Reference ;
101-
bald:array ns1:longitude ;
101+
bald:array this:longitude ;
102102
bald:first_value 0.0 ;
103103
bald:last_value 359.0 ;
104104
bald:shape "(360,)" ;
105105
CFTerms:standard_name <http://vocab.nerc.ac.uk/standard_name/longitude/> ;
106106
NetCDF:units "degrees_east" .
107107

108-
ns1:time a bald:Array,
108+
this:time a bald:Array,
109109
bald:Reference ;
110-
bald:array ns1:time ;
110+
bald:array this:time ;
111111
bald:first_value "2006-04-01T00:00:00"^^xsd:dateTime ;
112112
bald:shape "(1,)" ;
113113
CFTerms:standard_name <http://vocab.nerc.ac.uk/standard_name/time/> ;

lib/bald/tests/integration/TTL/ProcessChain0300.ttl

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,27 @@
44
@prefix StatPP: <https://codes.nws.noaa.gov/StatisticalPostProcessing> .
55
@prefix bald: <http://binary-array-ld.net/latest/> .
66
@prefix cf_sname: <http://vocab.nerc.ac.uk/standard_name/> .
7-
@prefix ns1: <file://CDL/ProcessChain0300.cdl/> .
87
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
98
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
9+
@prefix this: <file://CDL/ProcessChain0300.cdl/> .
1010
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
1111
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
1212

1313
<file://CDL/ProcessChain0300.cdl> a bald:Container ;
14-
ns1:process_chain "gfsmos_process_chain" ;
15-
bald:contains ns1:gfsmos_process_chain,
16-
ns1:step1,
17-
ns1:step2 ;
14+
this:process_chain "gfsmos_process_chain" ;
15+
bald:contains this:gfsmos_process_chain,
16+
this:step1,
17+
this:step2 ;
1818
bald:isPrefixedBy "prefix_list" .
1919

20-
ns1:gfsmos_process_chain a bald:Subject ;
21-
ns1:OM_Process ( ns1:step1 ns1:step2 ) .
20+
this:gfsmos_process_chain a bald:Subject ;
21+
this:OM_Process ( this:step1 this:step2 ) .
2222

23-
ns1:step1 a bald:Subject ;
24-
ns1:LE_ProcessStep <https://codes.nws.noaa.gov/NumericalWeatherPrediction/Models/GFS13> ;
25-
ns1:LE_Source <https://codes.nws.noaa.gov/DataAssimilation/Methods/GDAS13> .
23+
this:step1 a bald:Subject ;
24+
this:LE_ProcessStep <https://codes.nws.noaa.gov/NumericalWeatherPrediction/Models/GFS13> ;
25+
this:LE_Source <https://codes.nws.noaa.gov/DataAssimilation/Methods/GDAS13> .
2626

27-
ns1:step2 a bald:Subject ;
28-
ns1:LE_ProcessStep <https://codes.nws.noaa.gov/StatisticalPostProcessing/Methods/GFSMOS05> ;
29-
ns1:LE_Source <https://codes.nws.noaa.gov/NumericalWeatherPrediction/Models/GFS13> .
27+
this:step2 a bald:Subject ;
28+
this:LE_ProcessStep <https://codes.nws.noaa.gov/StatisticalPostProcessing/Methods/GFSMOS05> ;
29+
this:LE_Source <https://codes.nws.noaa.gov/NumericalWeatherPrediction/Models/GFS13> .
3030

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
@prefix bald: <http://binary-array-ld.net/latest/> .
2-
@prefix ns1: <file://CDL/array_reference.cdl/> .
32
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
43
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
4+
@prefix this: <file://CDL/array_reference.cdl/> .
55
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
66
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
77

88
<file://CDL/array_reference.cdl> a bald:Container ;
9-
bald:contains ns1:child_variable,
10-
ns1:parent_variable ;
9+
bald:contains this:child_variable,
10+
this:parent_variable ;
1111
bald:isPrefixedBy "prefix_list" .
1212

13-
ns1:parent_variable a bald:Array ;
14-
bald:references ns1:child_variable ;
13+
this:parent_variable a bald:Array ;
14+
bald:references this:child_variable ;
1515
bald:shape "(11, 17)" .
1616

17-
ns1:child_variable a bald:Array,
17+
this:child_variable a bald:Array,
1818
bald:Reference ;
19-
bald:array ns1:child_variable ;
19+
bald:array this:child_variable ;
2020
bald:shape "(11, 17)" .
2121

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
@prefix bald: <http://binary-array-ld.net/latest/> .
2-
@prefix ns1: <http://example.org/base/> .
32
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
43
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
4+
@prefix this: <http://example.org/base/> .
55
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
66
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
77

88
<http://example.org/base> a bald:Container ;
9-
bald:contains ns1:child_variable,
10-
ns1:parent_variable ;
9+
bald:contains this:child_variable,
10+
this:parent_variable ;
1111
bald:isPrefixedBy "prefix_list" .
1212

13-
ns1:parent_variable a bald:Array ;
14-
bald:references ns1:child_variable ;
13+
this:parent_variable a bald:Array ;
14+
bald:references this:child_variable ;
1515
bald:shape "(11, 17)" .
1616

17-
ns1:child_variable a bald:Array,
17+
this:child_variable a bald:Array,
1818
bald:Reference ;
19-
bald:array ns1:child_variable ;
19+
bald:array this:child_variable ;
2020
bald:shape "(11, 17)" .
2121

0 commit comments

Comments
 (0)