|
5 | 5 |
|
6 | 6 | from __future__ import annotations |
7 | 7 |
|
| 8 | +from collections.abc import Iterable |
8 | 9 | from datetime import datetime |
9 | 10 | from typing import ( |
10 | 11 | Any, |
@@ -311,3 +312,41 @@ def __init__(self: Self, item: pystac.Item) -> None: |
311 | 312 |
|
312 | 313 | def __repr__(self: Self) -> str: |
313 | 314 | return f"<ItemProcessingExtension Item id={self.item.id}>" |
| 315 | + |
| 316 | + |
| 317 | +class AssetProcessingExtension(ProcessingExtension[pystac.Asset]): |
| 318 | + """A concrete implementation of :class:`ProcessingExtension` on an |
| 319 | + :class:`~pystac.Asset` that extends the Asset fields to include properties defined |
| 320 | + in the :stac-ext:`Processing Extension <processing>`. |
| 321 | +
|
| 322 | + This class should generally not be instantiated directly. Instead, call |
| 323 | + :meth:`ProcessingExtension.ext` on an :class:`~pystac.Asset` to extend it. |
| 324 | + """ |
| 325 | + |
| 326 | + asset_href: str |
| 327 | + """The ``href`` value of the :class:`~pystac.Asset` being extended.""" |
| 328 | + |
| 329 | + properties: dict[str, Any] |
| 330 | + """The :class:`~pystac.Asset` fields, including extension properties.""" |
| 331 | + |
| 332 | + additional_read_properties: Iterable[dict[str, Any]] | None = None |
| 333 | + """If present, this will be a list containing 1 dictionary representing the |
| 334 | + properties of the owning :class:`~pystac.Item`.""" |
| 335 | + |
| 336 | + def __init__(self, asset: pystac.Asset): |
| 337 | + self.asset_href = asset.href |
| 338 | + self.properties = asset.extra_fields |
| 339 | + if asset.owner and isinstance(asset.owner, pystac.Item): |
| 340 | + self.additional_read_properties = [asset.owner.properties] |
| 341 | + |
| 342 | + def __repr__(self) -> str: |
| 343 | + return f"<AssetProcessingExtension Asset href={self.asset_href}>" |
| 344 | + |
| 345 | + |
| 346 | +class ItemAssetsProcessingExtension(ProcessingExtension[pystac.ItemAssetDefinition]): |
| 347 | + properties: dict[str, Any] |
| 348 | + asset_defn: pystac.ItemAssetDefinition |
| 349 | + |
| 350 | + def __init__(self, item_asset: pystac.ItemAssetDefinition): |
| 351 | + self.asset_defn = item_asset |
| 352 | + self.properties = item_asset.properties |
0 commit comments