Skip to content

Commit 41ba524

Browse files
committed
interesting
1 parent 821ae80 commit 41ba524

File tree

5 files changed

+22
-19
lines changed

5 files changed

+22
-19
lines changed

lib/bald/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def __init__(self, attrs=None):
4141
if attrs is None:
4242
attrs = []
4343
self.attrs = attrs
44-
self._prefix_suffix = re.compile('(^(?:(?!_._).)*)_._((?!.*_._).*$)')
44+
self._prefix_suffix = re.compile('(^(?:(?!__).)*)__((?!.*__).*$)')
4545
_http_p = 'http[s]?://.*'
4646
self._http_uri = re.compile('{}'.format(_http_p))
4747
self._http_uri_prefix = re.compile('{}/|#'.format(_http_p))
@@ -50,8 +50,8 @@ def __init__(self, attrs=None):
5050
def prefixes(self):
5151
prefixes = {}
5252
for key, value in self.attrs.iteritems():
53-
if key.endswith('_._') and self._http_uri_prefix.match(value):
54-
pref = key.rstrip('_._')
53+
if key.endswith('__') and self._http_uri_prefix.match(value):
54+
pref = key.rstrip('__')
5555
if prefixes.has_key(pref):
5656
raise ValueError('This container has conflicting prefix definitions')
5757
prefixes[pref] = value
@@ -65,7 +65,7 @@ def unpack_uri(self, astring):
6565

6666
if self.prefixes().has_key(prefix):
6767
if self._http_uri.match(self.prefixes()[prefix]):
68-
result = astring.replace('{}_._'.format(prefix), self.prefixes()[prefix])
68+
result = astring.replace('{}__'.format(prefix), self.prefixes()[prefix])
6969
return result
7070

7171
@contextlib.contextmanager

lib/bald/tests/integration/test_validation.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,19 @@
77
from bald.tests import BaldTestCase
88

99
def _fattrs(f):
10-
f.attrs['bald_._'] = 'http://binary-array-ld.net/experimental/'
11-
f.attrs['bald_._type'] = 'bald_._Container'
10+
f.attrs['bald__'] = 'http://binary-array-ld.net/experimental/'
11+
f.attrs['rdf__'] = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
12+
f.attrs['rdf__type'] = 'bald__Container'
1213
return f
1314

1415
def _create_parent_child(f, pshape, cshape):
1516
dsetp = f.create_dataset("parent_dataset", pshape, dtype='i')
1617
dsetc = f.create_dataset("child_dataset", cshape, dtype='i')
17-
dsetp.attrs['bald_._type'] = 'bald_._Dataset'
18-
dsetp.attrs['bald_._reference'] = dsetc.ref
19-
dsetc.attrs['bald_._type'] = 'bald_._Dataset'
18+
dsetp.attrs['rdf__type'] = 'bald__Dataset'
19+
dsetp.attrs['bald__references'] = dsetc.ref
20+
dsetc.attrs['rdf__type'] = 'bald__Dataset'
21+
dsetc.attrs['rdf__type'] = 'bald__Reference'
22+
dsetc.attrs['bald__dataset'] = dsetc.ref
2023
return f
2124

2225

@@ -35,7 +38,7 @@ def test_invalid_uri(self):
3538
f = h5py.File(tfile, "w")
3639
f = _fattrs(f)
3740
f = _create_parent_child(f, (11, 17), (11, 17))
38-
f.attrs['bald_._turtle'] = 'bald_._walnut'
41+
f.attrs['bald__turtle'] = 'bald__walnut'
3942
f.close()
4043
self.assertFalse(bald.validate_hdf5(tfile))
4144

lib/bald/tests/test_array_reference.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66
from bald.tests import BaldTestCase
77

88
def _fattrs(f):
9-
f.attrs['bald_._'] = 'http://binary_array_ld.net/experimental'
10-
f.attrs['bald_._type'] = 'bald_._Container'
9+
f.attrs['bald__'] = 'http://binary_array_ld.net/experimental'
10+
f.attrs['bald__type'] = 'bald__Container'
1111
return f
1212

1313
def _create_parent_child(f, pshape, cshape):
1414
dsetp = f.create_dataset("parent_dataset", pshape, dtype='i')
1515
dsetc = f.create_dataset("child_dataset", cshape, dtype='i')
16-
dsetp.attrs['bald_._type'] = 'bald_._Dataset'
17-
dsetp.attrs['bald_._reference'] = dsetc.ref
18-
dsetc.attrs['bald_._type'] = 'bald_._Dataset'
16+
dsetp.attrs['bald__type'] = 'bald__Dataset'
17+
dsetp.attrs['bald__reference'] = dsetc.ref
18+
dsetc.attrs['bald__type'] = 'bald__Dataset'
1919
return f
2020

2121

lib/bald/tests/test_simple.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ def test_make_load_file(self):
2222
with self.temp_filename('.hdf') as tfile:
2323
f = h5py.File(tfile, "w")
2424
dset = f.create_dataset("mydataset", (100,), dtype='i')
25-
dset.attrs['bald_._'] = 'http://binary_array_ld.net/alpha'
25+
dset.attrs['bald__'] = 'http://binary_array_ld.net/experimental'
2626
f.close()
2727
newf = h5py.File(tfile, "r")
2828
nset = newf.get('mydataset')
2929
self.assertEqual(nset.shape, (100,))
3030
self.assertEqual(nset.dtype, 'int32')
31-
self.assertEqual(nset.attrs.get('bald_._'),
32-
'http://binary_array_ld.net/alpha')
31+
self.assertEqual(nset.attrs.get('bald__'),
32+
'http://binary_array_ld.net/experimental')
3333

3434

3535
if __name__ == '__main__':

lib/bald/validation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def _check_ref(pdataset, parray, cdataset, carray):
156156

157157
for attr, value in self.subject.attrs.iteritems():
158158
# should support subtypes
159-
if attr == 'bald_._reference':
159+
if attr == 'bald__references':
160160
# check if it's this type, otherwise exception)
161161
# if isinstance(value,
162162
child_dset = self.fhandle[value]

0 commit comments

Comments
 (0)