File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1818from .writer import Writer
1919
2020if TYPE_CHECKING :
21+ from .extensions .ext import AssetExt
2122 from .stac_object import STACObject
2223
2324
@@ -132,6 +133,18 @@ def to_dict(self) -> dict[str, Any]:
132133 data = super ().to_dict ()
133134 return {"href" : self .href , ** data }
134135
136+ @property
137+ def ext (self ) -> AssetExt :
138+ """Accessor for extension classes on this asset
139+
140+ Example::
141+
142+ asset.ext.proj.code = "EPSG:4326"
143+ """
144+ from pystac .extensions .ext import AssetExt
145+
146+ return AssetExt (stac_object = self )
147+
135148
136149class Assets (Protocol ):
137150 assets : dict [str , Asset ]
Original file line number Diff line number Diff line change 33import copy
44import warnings
55from enum import StrEnum
6- from typing import Any , ClassVar , override
6+ from typing import TYPE_CHECKING , Any , ClassVar , override
77
88from typing_extensions import deprecated
99
1313from .link import Link
1414from .rel_type import RelType
1515
16+ if TYPE_CHECKING :
17+ from .extensions .ext import CatalogExt
18+
1619
1720class Catalog (Container ):
1821 type : ClassVar [STAC_OBJECT_TYPE ] = "Catalog"
@@ -83,6 +86,18 @@ def to_dict(
8386 data ["description" ] = self .description
8487 return data
8588
89+ @property
90+ def ext (self ) -> CatalogExt :
91+ """Accessor for extension classes on this catalog
92+
93+ Example::
94+
95+ print(collection.ext.version)
96+ """
97+ from pystac .extensions .ext import CatalogExt
98+
99+ return CatalogExt (stac_object = self )
100+
86101
87102@deprecated ("CatalogType is deprecated" )
88103class CatalogType (StrEnum ):
Original file line number Diff line number Diff line change 2626from .utils import to_datetime_str
2727
2828if TYPE_CHECKING :
29+ from .extensions .ext import CollectionExt
2930 from .item import Item
3031 from .item_collection import ItemCollection
3132
@@ -218,6 +219,18 @@ def update_extent_from_items(self) -> None:
218219 """
219220 self .extent = Extent .from_items (self .get_items (recursive = True ))
220221
222+ @property
223+ def ext (self ) -> CollectionExt :
224+ """Accessor for extension classes on this collection
225+
226+ Example::
227+
228+ print(collection.ext.xarray)
229+ """
230+ from pystac .extensions .ext import CollectionExt
231+
232+ return CollectionExt (stac_object = self )
233+
221234
222235class Extent :
223236 def __init__ (
Original file line number Diff line number Diff line change 2929
3030if TYPE_CHECKING :
3131 from .collection import Collection
32+ from .extensions .ext import ItemExt
3233
3334
3435class Item (STACObject , Assets ):
@@ -241,6 +242,18 @@ def to_dict(
241242 def __geo_interface__ (self ) -> dict [str , Any ]:
242243 return self .to_dict (include_self_link = False )
243244
245+ @property
246+ def ext (self ) -> ItemExt :
247+ """Accessor for extension classes on this item
248+
249+ Example::
250+
251+ item.ext.proj.code = "EPSG:4326"
252+ """
253+ from pystac .extensions .ext import ItemExt
254+
255+ return ItemExt (stac_object = self )
256+
244257
245258@final
246259class Properties (
Original file line number Diff line number Diff line change 1616
1717if TYPE_CHECKING :
1818 from . import Catalog , Collection , Item
19+ from .extensions .ext import LinkExt
1920 from .stac_object import STACObject
2021
2122HIERARCHICAL_LINKS = [
@@ -318,3 +319,15 @@ def canonical(
318319 title = title ,
319320 media_type = MediaType .JSON ,
320321 )
322+
323+ @property
324+ def ext (self ) -> LinkExt :
325+ """Accessor for extension classes on this link
326+
327+ Example::
328+
329+ link.ext.file.size = 8675309
330+ """
331+ from pystac .extensions .ext import LinkExt
332+
333+ return LinkExt (stac_object = self )
You can’t perform that action at this time.
0 commit comments