Skip to content

Commit 7e535c6

Browse files
committed
Update Item Assets Extension docstrings
1 parent e45af8e commit 7e535c6

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

pystac/extensions/item_assets.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
https://github.com/stac-extensions/item-assets
44
"""
55

6+
from copy import deepcopy
67
from typing import Any, Dict, List, Optional
78

89
import pystac
@@ -22,11 +23,23 @@
2223

2324

2425
class AssetDefinition:
26+
"""Object that contains details about the datafiles that will be included in member
27+
Items for this Collection.
28+
29+
See the :stac-ext:`Asset Object <item-assets#asset-object>` for details.
30+
"""
31+
2532
def __init__(self, properties: Dict[str, Any]) -> None:
2633
self.properties = properties
2734

35+
def __eq__(self, o: object) -> bool:
36+
if not isinstance(o, AssetDefinition):
37+
return NotImplemented
38+
return self.to_dict() == o.to_dict()
39+
2840
@property
2941
def title(self) -> Optional[str]:
42+
"""Gets or sets the displayed title for clients and users."""
3043
return self.properties.get(ASSET_TITLE_PROP)
3144

3245
@title.setter
@@ -38,6 +51,9 @@ def title(self, v: Optional[str]) -> None:
3851

3952
@property
4053
def description(self) -> Optional[str]:
54+
"""Gets or sets a description of the Asset providing additional details, such as
55+
how it was processed or created. `CommonMark 0.29 <http://commonmark.org/`__
56+
syntax MAY be used for rich text representation."""
4157
return self.properties.get(ASSET_DESC_PROP)
4258

4359
@description.setter
@@ -49,6 +65,9 @@ def description(self, v: Optional[str]) -> None:
4965

5066
@property
5167
def media_type(self) -> Optional[str]:
68+
"""Gets or sets the `media type
69+
<https://github.com/radiantearth/stac-spec/tree/v1.0.0-rc.1/catalog-spec/catalog-spec.md#media-types>`__
70+
of the asset."""
5271
return self.properties.get(ASSET_TYPE_PROP)
5372

5473
@media_type.setter
@@ -60,6 +79,9 @@ def media_type(self, v: Optional[str]) -> None:
6079

6180
@property
6281
def roles(self) -> Optional[List[str]]:
82+
"""Gets or sets the `semantic roles
83+
<https://github.com/radiantearth/stac-spec/tree/v1.0.0-rc.1/item-spec/item-spec.md#asset-role-types>`__
84+
of the asset, similar to the use of rel in links."""
6385
return self.properties.get(ASSET_ROLES_PROP)
6486

6587
@roles.setter
@@ -69,7 +91,13 @@ def roles(self, v: Optional[List[str]]) -> None:
6991
else:
7092
self.properties[ASSET_ROLES_PROP] = v
7193

94+
def to_dict(self) -> Dict[str, Any]:
95+
"""Returns a JSON-like dictionary representing this ``AssetDefinition``."""
96+
return deepcopy(self.properties)
97+
7298
def create_asset(self, href: str) -> pystac.Asset:
99+
"""Creates a new :class:`~pystac.Asset` instance using the fields from this
100+
``AssetDefinition`` and the given ``href``."""
73101
return pystac.Asset(
74102
href=href,
75103
title=self.title,
@@ -96,6 +124,8 @@ def __init__(self, collection: pystac.Collection) -> None:
96124

97125
@property
98126
def item_assets(self) -> Dict[str, AssetDefinition]:
127+
"""Gets or sets a dictionary of assets that can be found in member Items. Maps
128+
the asset key to an :class:`AssetDefinition` instance."""
99129
result: Dict[str, Any] = get_required(
100130
self.collection.extra_fields.get(ITEM_ASSETS_PROP), self, ITEM_ASSETS_PROP
101131
)
@@ -118,6 +148,13 @@ def get_schema_uri(cls) -> str:
118148
def ext(
119149
cls, obj: pystac.Collection, add_if_missing: bool = False
120150
) -> "ItemAssetsExtension":
151+
"""Extends the given :class:`~pystac.Collection` with properties from the
152+
:stac-ext:`Item Assets Extension <item-assets>`.
153+
154+
Raises:
155+
156+
pystac.ExtensionTypeError : If an invalid object type is passed.
157+
"""
121158
if isinstance(obj, pystac.Collection):
122159
cls.validate_has_extension(obj, add_if_missing)
123160
return cls(obj)

0 commit comments

Comments
 (0)