Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use has_extension rather than deprecated validate_has_extension #134

Merged
merged 4 commits into from
Dec 18, 2023
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions odc/stac/_mdtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,30 +153,31 @@ def has_proj_ext(item: Union[pystac.item.Item, pystac.collection.Collection]) ->
"""
Check if STAC Item or Collection has projection extension.

:returns: ``True`` if PROJ exetension is enabled
:returns: ``True`` if PROJ extension is enabled
:returns: ``False`` if no PROJ extension was found
"""
try:
ProjectionExtension.validate_has_extension(item, add_if_missing=False)
if ProjectionExtension.has_extension(item):
return True
except pystac.errors.ExtensionNotImplemented:
return False
# can remove this block once pystac 1.9.0 is the min supported version
return any(
ext_name.startswith("https://stac-extensions.github.io/projection/")
for ext_name in item.stac_extensions
)


def has_raster_ext(item: Union[pystac.item.Item, pystac.collection.Collection]) -> bool:
"""
Check if STAC Item/Collection have EOExtension.
Check if STAC Item/Collection have RasterExtension.

:returns: ``True`` if Raster exetension is enabled
:returns: ``False`` if no Rasetr extension was found
:returns: ``True`` if Raster extension is enabled
:returns: ``False`` if no Raster extension was found
"""
try:
RasterExtension.validate_has_extension(item, add_if_missing=False)
if RasterExtension.has_extension(item):
return True
except pystac.errors.ExtensionNotImplemented:
return any(
ext_name.startswith("https://stac-extensions.github.io/raster/")
for ext_name in item.stac_extensions
# can remove this block once pystac 1.9.0 is the min supported version
return any(
ext_name.startswith("https://stac-extensions.github.io/raster/")
for ext_name in item.stac_extensions
)
Kirill888 marked this conversation as resolved.
Show resolved Hide resolved


Expand Down
Loading