Skip to content

Commit

Permalink
Rename to matches_object_type
Browse files Browse the repository at this point in the history
  • Loading branch information
duckontheweb committed Jun 17, 2021
1 parent 1fbf4c2 commit a6aa201
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions pystac/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ def from_dict(
info = identify_stac_object(d)
d = migrate_to_latest(d, info)

if not cls.dict_matches_object_type(d):
if not cls.matches_object_type(d):
raise STACTypeError(f"{d} does not represent a {cls.__name__} instance")

catalog_type = CatalogType.determine_type(d)
Expand Down Expand Up @@ -964,5 +964,5 @@ def from_file(cls, href: str, stac_io: Optional[pystac.StacIO] = None) -> "Catal
return result

@classmethod
def dict_matches_object_type(cls, d: Dict[str, Any]) -> bool:
def matches_object_type(cls, d: Dict[str, Any]) -> bool:
return identify_stac_object_type(d) == STACObjectType.CATALOG
4 changes: 2 additions & 2 deletions pystac/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ def from_dict(
info = identify_stac_object(d)
d = migrate_to_latest(d, info)

if not cls.dict_matches_object_type(d):
if not cls.matches_object_type(d):
raise STACTypeError(f"{d} does not represent a {cls.__name__} instance")

catalog_type = CatalogType.determine_type(d)
Expand Down Expand Up @@ -685,5 +685,5 @@ def from_file(
return result

@classmethod
def dict_matches_object_type(cls, d: Dict[str, Any]) -> bool:
def matches_object_type(cls, d: Dict[str, Any]) -> bool:
return identify_stac_object_type(d) == STACObjectType.COLLECTION
4 changes: 2 additions & 2 deletions pystac/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ def from_dict(
info = identify_stac_object(d)
d = migrate_to_latest(d, info)

if not cls.dict_matches_object_type(d):
if not cls.matches_object_type(d):
raise pystac.STACTypeError(
f"{d} does not represent a {cls.__name__} instance"
)
Expand Down Expand Up @@ -990,5 +990,5 @@ def from_file(cls, href: str, stac_io: Optional[pystac.StacIO] = None) -> "Item"
return result

@classmethod
def dict_matches_object_type(cls, d: Dict[str, Any]) -> bool:
def matches_object_type(cls, d: Dict[str, Any]) -> bool:
return identify_stac_object_type(d) == STACObjectType.ITEM
2 changes: 1 addition & 1 deletion pystac/stac_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ def from_dict(

@classmethod
@abstractmethod
def dict_matches_object_type(cls, d: Dict[str, Any]) -> bool:
def matches_object_type(cls, d: Dict[str, Any]) -> bool:
"""Returns a boolean indicating whether the given dictionary represents a valid
instance of this :class:`~STACObject` sub-class.
Expand Down
4 changes: 3 additions & 1 deletion tests/test_writing.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ def validate_catalog_link_type(
cat_dict = pystac.StacIO.default().read_json(href)
cat = pystac.read_file(href)
if not isinstance(cat, pystac.Catalog):
raise pystac.STACTypeError(f"File at {href} is a {cat.STAC_OBJECT_TYPE} not a Catalog.")
raise pystac.STACTypeError(
f"File at {href} is a {cat.STAC_OBJECT_TYPE} not a Catalog."
)

rels = set([link["rel"] for link in cat_dict["links"]])
self.assertEqual("self" in rels, should_include_self)
Expand Down

0 comments on commit a6aa201

Please sign in to comment.