Skip to content

Commit c8478e7

Browse files
committed
Rename Asset.properties to Asset.extra_fields
1 parent 2fb24b8 commit c8478e7

19 files changed

+74
-75
lines changed

pystac/asset.py

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from copy import copy
22
from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union
33

4-
import pystac
54
from pystac.utils import is_absolute_href, make_absolute_href
65

76
if TYPE_CHECKING:
@@ -24,7 +23,7 @@ class Asset:
2423
are preferred. See :class:`~pystac.MediaType` for common media types.
2524
roles : Optional, Semantic roles (i.e. thumbnail, overview,
2625
data, metadata) of the asset.
27-
properties : Optional, additional properties for this asset. This is used
26+
extra_fields : Optional, additional fields for this asset. This is used
2827
by extensions as a way to serialize and deserialize properties on asset
2928
object JSON.
3029
"""
@@ -48,12 +47,12 @@ class Asset:
4847
"""Optional, Semantic roles (i.e. thumbnail, overview, data, metadata) of the
4948
asset."""
5049

51-
owner: Optional[Union[pystac.Item, pystac.Collection]]
50+
owner: Optional[Union["Item_Type", "Collection_Type"]]
5251
"""The :class:`~pystac.Item` or :class:`~pystac.Collection` that this asset belongs
5352
to, or ``None`` if it has no owner."""
5453

55-
properties: Optional[Dict[str, Any]]
56-
"""Optional, additional properties for this asset. This is used by extensions as a
54+
extra_fields: Dict[str, Any]
55+
"""Optional, additional fields for this asset. This is used by extensions as a
5756
way to serialize and deserialize properties on asset object JSON."""
5857

5958
def __init__(
@@ -63,18 +62,14 @@ def __init__(
6362
description: Optional[str] = None,
6463
media_type: Optional[str] = None,
6564
roles: Optional[List[str]] = None,
66-
properties: Optional[Dict[str, Any]] = None,
65+
extra_fields: Optional[Dict[str, Any]] = None,
6766
) -> None:
6867
self.href = href
6968
self.title = title
7069
self.description = description
7170
self.media_type = media_type
7271
self.roles = roles
73-
74-
if properties is not None:
75-
self.properties = properties
76-
else:
77-
self.properties = {}
72+
self.extra_fields = extra_fields or {}
7873

7974
# The Item which owns this Asset.
8075
self.owner = None
@@ -125,8 +120,8 @@ def to_dict(self) -> Dict[str, Any]:
125120
if self.description is not None:
126121
d["description"] = self.description
127122

128-
if self.properties is not None and len(self.properties) > 0:
129-
for k, v in self.properties.items():
123+
if self.extra_fields is not None and len(self.extra_fields) > 0:
124+
for k, v in self.extra_fields.items():
130125
d[k] = v
131126

132127
if self.roles is not None:
@@ -146,7 +141,7 @@ def clone(self) -> "Asset":
146141
description=self.description,
147142
media_type=self.media_type,
148143
roles=self.roles,
149-
properties=self.properties,
144+
extra_fields=self.extra_fields,
150145
)
151146

152147
def __repr__(self) -> str:
@@ -175,5 +170,5 @@ def from_dict(d: Dict[str, Any]) -> "Asset":
175170
title=title,
176171
description=description,
177172
roles=roles,
178-
properties=properties,
173+
extra_fields=properties,
179174
)

pystac/extensions/datacube.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ class AssetDatacubeExtension(DatacubeExtension[pystac.Asset]):
391391

392392
def __init__(self, asset: pystac.Asset):
393393
self.asset_href = asset.href
394-
self.properties = asset.properties
394+
self.properties = asset.extra_fields
395395
if asset.owner and isinstance(asset.owner, pystac.Item):
396396
self.additional_read_properties = [asset.owner.properties]
397397
else:

pystac/extensions/eo.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -408,9 +408,9 @@ def _get_bands(self) -> Optional[List[Band]]:
408408
if bands is None:
409409
asset_bands: List[Dict[str, Any]] = []
410410
for _, value in self.item.get_assets().items():
411-
if BANDS_PROP in value.properties:
411+
if BANDS_PROP in value.extra_fields:
412412
asset_bands.extend(
413-
cast(List[Dict[str, Any]], value.properties.get(BANDS_PROP))
413+
cast(List[Dict[str, Any]], value.extra_fields.get(BANDS_PROP))
414414
)
415415
if any(asset_bands):
416416
bands = asset_bands
@@ -454,7 +454,7 @@ def _get_bands(self) -> Optional[List[Band]]:
454454

455455
def __init__(self, asset: pystac.Asset):
456456
self.asset_href = asset.href
457-
self.properties = asset.properties
457+
self.properties = asset.extra_fields
458458
if asset.owner and isinstance(asset.owner, pystac.Item):
459459
self.additional_read_properties = [asset.owner.properties]
460460

pystac/extensions/file.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class FileExtension(PropertiesExtension, ExtensionManagementMixin[pystac.Item]):
103103

104104
def __init__(self, asset: pystac.Asset):
105105
self.asset_href = asset.href
106-
self.properties = asset.properties
106+
self.properties = asset.extra_fields
107107
if asset.owner and isinstance(asset.owner, pystac.Item):
108108
self.additional_read_properties = [asset.owner.properties]
109109

pystac/extensions/item_assets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def create_asset(self, href: str) -> pystac.Asset:
7676
description=self.description,
7777
media_type=self.media_type,
7878
roles=self.roles,
79-
properties={
79+
extra_fields={
8080
k: v
8181
for k, v in self.properties.items()
8282
if k

pystac/extensions/label.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ def add_labels(
665665
self.obj.add_asset(
666666
"labels",
667667
pystac.Asset(
668-
href=href, title=title, media_type=media_type, properties=properties
668+
href=href, title=title, media_type=media_type, extra_fields=properties
669669
),
670670
)
671671

pystac/extensions/pointcloud.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ def __repr__(self) -> str:
552552
class AssetPointcloudExtension(PointcloudExtension[pystac.Asset]):
553553
def __init__(self, asset: pystac.Asset):
554554
self.asset_href = asset.href
555-
self.properties = asset.properties
555+
self.properties = asset.extra_fields
556556
if asset.owner and isinstance(asset.owner, pystac.Item):
557557
self.additional_read_properties = [asset.owner.properties]
558558
self.repr_id = f"href={asset.href} item.id={asset.owner.id}"

pystac/extensions/projection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ class AssetProjectionExtension(ProjectionExtension[pystac.Asset]):
314314

315315
def __init__(self, asset: pystac.Asset):
316316
self.asset_href = asset.href
317-
self.properties = asset.properties
317+
self.properties = asset.extra_fields
318318
if asset.owner and isinstance(asset.owner, pystac.Item):
319319
self.additional_read_properties = [asset.owner.properties]
320320

pystac/extensions/raster.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ class RasterExtension(PropertiesExtension, ExtensionManagementMixin[pystac.Item]
647647

648648
def __init__(self, asset: pystac.Asset):
649649
self.asset_href = asset.href
650-
self.properties = asset.properties
650+
self.properties = asset.extra_fields
651651
if asset.owner and isinstance(asset.owner, pystac.Item):
652652
self.additional_read_properties = [asset.owner.properties]
653653

pystac/extensions/sar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ def __repr__(self) -> str:
334334
class AssetSarExtension(SarExtension[pystac.Asset]):
335335
def __init__(self, asset: pystac.Asset):
336336
self.asset_href = asset.href
337-
self.properties = asset.properties
337+
self.properties = asset.extra_fields
338338
if asset.owner and isinstance(asset.owner, pystac.Item):
339339
self.additional_read_properties = [asset.owner.properties]
340340

0 commit comments

Comments
 (0)