@@ -87,8 +87,8 @@ CDM.maskingvalue(ds::ZarrDataset) = ds.maskingvalue
87
87
ZarrDataset(f::Function,url::AbstractString,mode = "r";
88
88
maskingvalue = missing)
89
89
90
- Open the zarr dataset at the url or path `url`. The mode can only be `"r"` (read-only)
91
- or `"c"` (create). `ds` supports the API of the
90
+ Open the zarr dataset at the url or path `url`. The mode can be `"r"` (read-only),
91
+ `"w"` (write), or `"c"` (create). `ds` supports the API of the
92
92
[JuliaGeo/CommonDataModel.jl](https://github.com/JuliaGeo/CommonDataModel.jl).
93
93
The experimental `_omitcode` allows to define which HTTP error code should be used
94
94
for missing chunks. For compatibility with python's Zarr, the HTTP error 403
@@ -128,7 +128,7 @@ zos1 = ZarrDataset(url) do ds
128
128
end # implicit call to close(ds)
129
129
```
130
130
"""
131
- function ZarrDataset (url:: AbstractString ,mode = " r" ;
131
+ function ZarrDataset (url:: AbstractString , mode = " r" ;
132
132
parentdataset = nothing ,
133
133
_omitcode = [404 ,403 ],
134
134
maskingvalue = missing ,
@@ -137,16 +137,18 @@ function ZarrDataset(url::AbstractString,mode = "r";
137
137
138
138
dimensions = OrderedDict {Symbol,Int} ()
139
139
140
- zg = if mode == " r "
141
- zg = Zarr. zopen (url,mode)
140
+ zg = if mode in ( " w " , " r " )
141
+ zg = Zarr. zopen (url, mode)
142
142
elseif mode == " c"
143
143
store = Zarr. DirectoryStore (url)
144
- zg = zgroup (store, " " ,attrs = Dict {String,Any} (attrib))
144
+ zg = zgroup (store, " " , attrs = Dict {String,Any} (attrib))
145
+ else
146
+ throw (ArgumentError (" mode must be \" r\" , \" w\" or \" c\" , got $mode " ))
145
147
end
146
148
ZarrDataset (zg; mode, parentdataset, _omitcode, maskingvalue, attrib)
147
149
end
148
150
149
- function ZarrDataset (store:: Zarr.AbstractStore ,mode = " r" ;
151
+ function ZarrDataset (store:: Zarr.AbstractStore , mode = " r" ;
150
152
parentdataset = nothing ,
151
153
_omitcode = [404 ,403 ],
152
154
maskingvalue = missing ,
@@ -191,7 +193,7 @@ ZarrDataset(fnames::AbstractArray{<:AbstractString,N}, args...; kwargs...) where
191
193
MFDataset (ZarrDataset,fnames, args... ; kwargs... )
192
194
193
195
194
- function ZarrDataset (f:: Function ,args... ; kwargs... )
196
+ function ZarrDataset (f:: Functiot ,args... ; kwargs... )
195
197
ds = ZarrDataset (args... ; kwargs... )
196
198
try
197
199
f (ds)
0 commit comments