File tree 2 files changed +20
-1
lines changed
2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -582,11 +582,15 @@ def norm_key(k: BandIdentifier) -> BandKey:
582
582
("band", i) -> ("band", i)
583
583
"band" -> ("band", 1)
584
584
"band.3" -> ("band", 3)
585
+ "band.tiff" -> ("band.tiff", 1)
585
586
"""
586
587
if isinstance (k , str ):
587
588
parts = k .rsplit ("." , 1 )
588
589
if len (parts ) == 2 :
589
- return parts [0 ], int (parts [1 ])
590
+ try :
591
+ return parts [0 ], int (parts [1 ])
592
+ except ValueError :
593
+ return (k , 1 )
590
594
return (k , 1 )
591
595
return k
592
596
Original file line number Diff line number Diff line change 10
10
RasterGroupMetadata ,
11
11
RasterLoadParams ,
12
12
RasterSource ,
13
+ norm_key ,
13
14
)
14
15
from odc .stac import ParsedItem , RasterCollectionMetadata
15
16
from odc .stac .testing .stac import b_ , mk_parsed_item
@@ -206,3 +207,17 @@ def test_tokenize(parsed_item_ab: ParsedItem):
206
207
assert tokenize (RasterLoadParams ()) == tokenize (RasterLoadParams ())
207
208
assert tokenize (RasterLoadParams ("uint8" )) == tokenize (RasterLoadParams ("uint8" ))
208
209
assert tokenize (RasterLoadParams ("uint8" )) != tokenize (RasterLoadParams ("uint32" ))
210
+
211
+
212
+ @pytest .mark .parametrize (
213
+ "name, expected" ,
214
+ [
215
+ ("a" , ("a" , 1 )),
216
+ ("a.1" , ("a" , 1 )),
217
+ ("a.2" , ("a" , 2 )),
218
+ (("b" , 1 ), ("b" , 1 )),
219
+ ("foo.tiff" , ("foo.tiff" , 1 )),
220
+ ],
221
+ )
222
+ def test_normkey (name , expected ):
223
+ assert norm_key (name ) == expected
You can’t perform that action at this time.
0 commit comments