|
9 | 9 | from zarr.creation import (array, create, empty, empty_like, full, full_like,
|
10 | 10 | normalize_store_arg, ones, ones_like, zeros,
|
11 | 11 | zeros_like)
|
12 |
| -from zarr.errors import (err_contains_array, err_contains_group, |
13 |
| - err_group_not_found, err_read_only) |
| 12 | +from zarr.errors import ( |
| 13 | + ContainsArrayError, |
| 14 | + ContainsGroupError, |
| 15 | + GroupNotFoundError, |
| 16 | + ReadOnlyError, |
| 17 | +) |
14 | 18 | from zarr.meta import decode_group_metadata
|
15 | 19 | from zarr.storage import (MemoryStore, attrs_key, contains_array,
|
16 | 20 | contains_group, group_meta_key, init_group, listdir,
|
@@ -105,14 +109,14 @@ def __init__(self, store, path=None, read_only=False, chunk_store=None,
|
105 | 109 |
|
106 | 110 | # guard conditions
|
107 | 111 | if contains_array(store, path=self._path):
|
108 |
| - err_contains_array(path) |
| 112 | + raise ContainsArrayError(path) |
109 | 113 |
|
110 | 114 | # initialize metadata
|
111 | 115 | try:
|
112 | 116 | mkey = self._key_prefix + group_meta_key
|
113 | 117 | meta_bytes = store[mkey]
|
114 | 118 | except KeyError:
|
115 |
| - err_group_not_found(path) |
| 119 | + raise GroupNotFoundError(path) |
116 | 120 | else:
|
117 | 121 | meta = decode_group_metadata(meta_bytes)
|
118 | 122 | self._meta = meta
|
@@ -645,7 +649,7 @@ def _write_op(self, f, *args, **kwargs):
|
645 | 649 |
|
646 | 650 | # guard condition
|
647 | 651 | if self._read_only:
|
648 |
| - err_read_only() |
| 652 | + raise ReadOnlyError() |
649 | 653 |
|
650 | 654 | if self._synchronizer is None:
|
651 | 655 | # no synchronization
|
@@ -1154,24 +1158,24 @@ def open_group(store=None, mode='a', cache_attrs=True, synchronizer=None, path=N
|
1154 | 1158 |
|
1155 | 1159 | if mode in ['r', 'r+']:
|
1156 | 1160 | if contains_array(store, path=path):
|
1157 |
| - err_contains_array(path) |
| 1161 | + raise ContainsArrayError(path) |
1158 | 1162 | elif not contains_group(store, path=path):
|
1159 |
| - err_group_not_found(path) |
| 1163 | + raise GroupNotFoundError(path) |
1160 | 1164 |
|
1161 | 1165 | elif mode == 'w':
|
1162 | 1166 | init_group(store, overwrite=True, path=path, chunk_store=chunk_store)
|
1163 | 1167 |
|
1164 | 1168 | elif mode == 'a':
|
1165 | 1169 | if contains_array(store, path=path):
|
1166 |
| - err_contains_array(path) |
| 1170 | + raise ContainsArrayError(path) |
1167 | 1171 | if not contains_group(store, path=path):
|
1168 | 1172 | init_group(store, path=path, chunk_store=chunk_store)
|
1169 | 1173 |
|
1170 | 1174 | elif mode in ['w-', 'x']:
|
1171 | 1175 | if contains_array(store, path=path):
|
1172 |
| - err_contains_array(path) |
| 1176 | + raise ContainsArrayError(path) |
1173 | 1177 | elif contains_group(store, path=path):
|
1174 |
| - err_contains_group(path) |
| 1178 | + raise ContainsGroupError(path) |
1175 | 1179 | else:
|
1176 | 1180 | init_group(store, path=path, chunk_store=chunk_store)
|
1177 | 1181 |
|
|
0 commit comments