Skip to content

Commit ab3e791

Browse files
committed
Clarify conforms_to v. assert_conforms_to usage
1 parent 1ab5e7d commit ab3e791

File tree

5 files changed

+902
-16
lines changed

5 files changed

+902
-16
lines changed

pystac_client/client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def get_collections(self) -> Iterable[CollectionClient]:
9494
Return:
9595
Iterable[CollectionClient]: Iterator through Collections in Catalog/API
9696
"""
97-
if self._stac_io.assert_conforms_to(ConformanceClasses.COLLECTIONS):
97+
if self._stac_io.conforms_to(ConformanceClasses.COLLECTIONS):
9898
url = self.get_self_href() + '/collections'
9999
for page in self._stac_io.get_pages(url):
100100
if 'collections' not in page:
@@ -111,7 +111,7 @@ def get_items(self) -> Iterable["Item_Type"]:
111111
Return:
112112
Iterable[Item]:: Generator of items whose parent is this catalog.
113113
"""
114-
if self._stac_io.assert_conforms_to(ConformanceClasses.ITEM_SEARCH):
114+
if self._stac_io.conforms_to(ConformanceClasses.ITEM_SEARCH):
115115
search = self.search()
116116
yield from search.get_items()
117117
else:
@@ -126,7 +126,7 @@ def get_all_items(self) -> Iterable["Item_Type"]:
126126
catalogs or collections connected to this catalog through
127127
child links.
128128
"""
129-
if self._stac_io.assert_conforms_to(ConformanceClasses.ITEM_SEARCH):
129+
if self._stac_io.conforms_to(ConformanceClasses.ITEM_SEARCH):
130130
yield from self.get_items()
131131
else:
132132
yield from super().get_items()

pystac_client/stac_api_io.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -210,21 +210,16 @@ def get_pages(self, url, method='GET', parameters={}) -> Iterator[Dict]:
210210
next_link = next((link for link in page.get('links', []) if link['rel'] == 'next'),
211211
None)
212212

213-
def assert_conforms_to(self, conformance_class: ConformanceClasses):
214-
"""Whether the API conforms to the given standard. This method only checks against the ``"conformsTo"``
215-
property from the API landing page and does not make any additional calls to a ``/conformance`` endpoint
216-
even if the API provides such an endpoint.
213+
def assert_conforms_to(self, conformance_class: ConformanceClasses) -> None:
214+
"""Raises a :exc:`NotImplementedError` if the API does not publish the given conformance class. This method
215+
only checks against the ``"conformsTo"`` property from the API landing page and does not make any additional
216+
calls to a ``/conformance`` endpoint even if the API provides such an endpoint.
217217
218218
Args:
219-
key: The ``ConformanceClasses`` key to check conformance against.
220-
221-
Return:
222-
bool: Indicates if the API conforms to the given spec or URI.
219+
conformance_class: The ``ConformanceClasses`` key to check conformance against.
223220
"""
224221
if not self.conforms_to(conformance_class):
225222
raise NotImplementedError(f"{conformance_class} not supported")
226-
else:
227-
return True
228223

229224
def conforms_to(self, conformance_class: ConformanceClasses) -> bool:
230225
"""Whether the API conforms to the given standard. This method only checks against the ``"conformsTo"``

0 commit comments

Comments
 (0)