Skip to content

Commit

Permalink
fix unwanted breacking change with img_profiles.get not allowing de…
Browse files Browse the repository at this point in the history
…fault values (#180)
  • Loading branch information
vincentsarago authored May 7, 2020
1 parent 08e352a commit 1d3f1bc
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2.0a6 (2020-05-06)
------------------
- fix unwanted breacking change with `img_profiles.get` not allowing default values

2.0a5 (2020-05-06)
------------------
- make `rio_tiler.io.landsat8.tile` return Uint16 data and not float32 (#173)
Expand Down
6 changes: 4 additions & 2 deletions rio_tiler/profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@ def __init__(self):
}
)

def get(self, key):
def get(self, key, default=None):
"""Like normal item access but return a copy of the key."""
return self.data.get(key, {}).copy()
if key in (self.keys()):
return self.data[key].copy()
return default

def __getitem__(self, key):
"""Like normal item access but return a copy of the key."""
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

setup(
name="rio-tiler",
version="2.0a5",
version="2.0a6",
python_requires=">=3",
description=u"""Get mercator tile from CloudOptimized GeoTIFF and other cloud hosted raster such as CBERS-4, Sentinel-2, Sentinel-1 and Landsat-8 AWS PDS""",
long_description=readme,
Expand Down
3 changes: 3 additions & 0 deletions tests/test_profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ def test_gdal_profiles():
prof["test"] = True
new_prof = img_profiles["jpeg"]
assert not new_prof.get("test")

prof = img_profiles.get("jpe", {"a": "b"})
assert prof == {"a": "b"}

0 comments on commit 1d3f1bc

Please sign in to comment.