@@ -87,8 +87,8 @@ CDM.maskingvalue(ds::ZarrDataset) = ds.maskingvalue
8787 ZarrDataset(f::Function,url::AbstractString,mode = "r";
8888 maskingvalue = missing)
8989
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
9292[JuliaGeo/CommonDataModel.jl](https://github.com/JuliaGeo/CommonDataModel.jl).
9393The experimental `_omitcode` allows to define which HTTP error code should be used
9494for missing chunks. For compatibility with python's Zarr, the HTTP error 403
@@ -128,7 +128,7 @@ zos1 = ZarrDataset(url) do ds
128128end # implicit call to close(ds)
129129```
130130"""
131- function ZarrDataset (url:: AbstractString ,mode = " r" ;
131+ function ZarrDataset (url:: AbstractString , mode = " r" ;
132132 parentdataset = nothing ,
133133 _omitcode = [404 ,403 ],
134134 maskingvalue = missing ,
@@ -137,16 +137,18 @@ function ZarrDataset(url::AbstractString,mode = "r";
137137
138138 dimensions = OrderedDict {Symbol,Int} ()
139139
140- zg = if mode == " r "
141- zg = Zarr. zopen (url,mode)
140+ zg = if mode in ( " w " , " r " )
141+ zg = Zarr. zopen (url, mode)
142142 elseif mode == " c"
143143 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 " ))
145147 end
146148 ZarrDataset (zg; mode, parentdataset, _omitcode, maskingvalue, attrib)
147149end
148150
149- function ZarrDataset (store:: Zarr.AbstractStore ,mode = " r" ;
151+ function ZarrDataset (store:: Zarr.AbstractStore , mode = " r" ;
150152 parentdataset = nothing ,
151153 _omitcode = [404 ,403 ],
152154 maskingvalue = missing ,
0 commit comments