From d73d4ad6dd241a8486b7535efc6eb44a8b001683 Mon Sep 17 00:00:00 2001 From: vincentsarago Date: Wed, 6 May 2020 20:37:47 -0400 Subject: [PATCH] fix unwanted breacking change with `img_profiles.get` not allowing default values --- CHANGES.txt | 4 ++++ rio_tiler/profiles.py | 6 ++++-- setup.py | 2 +- tests/test_profiles.py | 3 +++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 8abcc776..7acb7224 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -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) diff --git a/rio_tiler/profiles.py b/rio_tiler/profiles.py index b8859a73..51808621 100644 --- a/rio_tiler/profiles.py +++ b/rio_tiler/profiles.py @@ -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.""" diff --git a/setup.py b/setup.py index df39fdf2..55ddfc32 100644 --- a/setup.py +++ b/setup.py @@ -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, diff --git a/tests/test_profiles.py b/tests/test_profiles.py index 0453e56c..20bfd7c3 100644 --- a/tests/test_profiles.py +++ b/tests/test_profiles.py @@ -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"}