pytac.extensions.base#
- class pystac.extensions.base.ExtensionManagementMixin[source]#
Abstract base class with methods for adding and removing extensions from STAC Objects. This class is generic over the type of object being extended (e.g.
Item).Concrete extension implementations should inherit from this class and either provide a concrete type or a bounded type variable.
See
EOExtensionfor an example implementation.- classmethod add_to(obj: S) None[source]#
Add the schema URI for this extension to the
stac_extensionslist for the given object, if it is not already present.
- classmethod ensure_has_extension(obj: S, add_if_missing: bool = False) None[source]#
Given a
STACObject, checks if the object has this extension’s schema URI in itsstac_extensionslist. Ifadd_if_missingisTrue, the schema URI will be added to the object.- Parameters:
obj – The object to validate.
add_if_missing – Whether to add the schema URI to the object if it is not already present. Defaults to False.
- classmethod ensure_owner_has_extension(asset_or_link: Asset | ItemAssetDefinition | Link, add_if_missing: bool = False) None[source]#
Given an
Asset, checks if the asset’s owner has this extension’s schema URI in itsstac_extensionslist. Ifadd_if_missingisTrue, the schema URI will be added to the owner.- Parameters:
asset – The asset whose owner should be validated.
add_if_missing – Whether to add the schema URI to the owner if it is not already present. Defaults to False.
- Raises:
STACError – If
add_if_missingisTrueandasset.ownerisNone.
- abstract classmethod get_schema_uri() str[source]#
Gets the schema URI associated with this extension.
- classmethod get_schema_uris() list[str][source]#
Gets a list of schema URIs associated with this extension.
- classmethod has_extension(obj: S) bool[source]#
Check if the given object implements this extension by checking
pystac.STACObject.stac_extensionsfor this extension’s schema URI.
- classmethod remove_from(obj: S) None[source]#
Remove the schema URI for this extension from the
pystac.STACObject.stac_extensionslist for the given object.
- classmethod validate_has_extension(obj: S, add_if_missing: bool = False) None[source]#
DEPRECATED
Deprecated since version 1.9: Use
ensure_has_extension()instead.Given a
STACObject, checks if the object has this extension’s schema URI in itsstac_extensionslist. Ifadd_if_missingisTrue, the schema URI will be added to the object.- Parameters:
obj – The object to validate.
add_if_missing – Whether to add the schema URI to the object if it is not already present. Defaults to False.
- classmethod validate_owner_has_extension(asset: Asset | ItemAssetDefinition, add_if_missing: bool = False) None[source]#
DEPRECATED
Deprecated since version 1.9: Use
ensure_owner_has_extension()instead.Given an
Asset, checks if the asset’s owner has this extension’s schema URI in itsstac_extensionslist. Ifadd_if_missingisTrue, the schema URI will be added to the owner.- Parameters:
asset – The asset whose owner should be validated.
add_if_missing – Whether to add the schema URI to the owner if it is not already present. Defaults to False.
- Raises:
STACError – If
add_if_missingisTrueandasset.ownerisNone.
- class pystac.extensions.base.PropertiesExtension[source]#
Abstract base class for extending the properties of an
Itemto include properties defined by a STAC Extension.This class should not be instantiated directly. Instead, create an extension-specific class that inherits from this class and instantiate that. See
EOExtensionfor an example.- additional_read_properties: Iterable[dict[str, Any]] | None = None#
Additional read-only properties accessible from the extended object.
These are used when extending an
Assetto give access to the properties of the owningItem. If a property exists in bothadditional_read_propertiesandproperties, the value inadditional_read_propertieswill take precedence.
- properties: dict[str, Any]#
The properties that this extension wraps.
The extension which implements PropertiesExtension can use
_get_propertyand_set_propertyto get and set values on this instance. Note that _set_properties mutates the properties directly.
- class pystac.extensions.base.SummariesExtension(collection: Collection)[source]#
Base class for extending the properties in
pystac.Collection.summariesto include properties defined by a STAC Extension.This class should generally not be instantiated directly. Instead, create an extension-specific class that inherits from this class and instantiate that. See
SummariesEOExtensionfor an example.- summaries: Summaries#
The summaries for the
Collectionbeing extended.