pystac.extensions.file#

Implements the File Info Extension.

class pystac.extensions.file.ByteOrder(value)[source]#

Bases: pystac.utils.StringEnum

List of allows values for the "file:byte_order" field defined by the File Info Extension.

BIG_ENDIAN = 'big-endian'#
LITTLE_ENDIAN = 'little-endian'#
class pystac.extensions.file.FileExtension(asset: pystac.asset.Asset)[source]#

Bases: pystac.extensions.base.PropertiesExtension, pystac.extensions.base.ExtensionManagementMixin[Union[pystac.collection.Collection, pystac.item.Item]]

A class that can be used to extend the properties of an Asset with properties from the File Info Extension.

To create an instance of FileExtension, use the FileExtension.ext() method. For example:

>>> asset: pystac.Asset = ...
>>> file_ext = FileExtension.ext(asset)
additional_read_properties: Optional[Iterable[Dict[str, Any]]] = None#

If present, this will be a list containing 1 dictionary representing the properties of the owning Item.

apply(byte_order: Optional[pystac.extensions.file.ByteOrder] = None, checksum: Optional[str] = None, header_size: Optional[int] = None, size: Optional[int] = None, values: Optional[List[pystac.extensions.file.MappingObject]] = None) None[source]#

Applies file extension properties to the extended Item.

Parameters
  • byte_order – Optional byte order of integer values in the file. One of "big-endian" or "little-endian".

  • checksum – Optional multihash for the corresponding file, encoded as hexadecimal (base 16) string with lowercase letters.

  • header_size – Optional header size of the file, in bytes.

  • size – Optional size of the file, in bytes.

  • values – Optional list of MappingObject instances that lists the values that are in the file and describe their meaning. See the Mapping Object docs for an example. If given, at least one array element is required.

asset_href: str#

The href value of the Asset being extended.

property byte_order: Optional[pystac.extensions.file.ByteOrder]#

Gets or sets the byte order of integer values in the file. One of big-endian or little-endian.

property checksum: Optional[str]#

Get or sets the multihash for the corresponding file, encoded as hexadecimal (base 16) string with lowercase letters.

classmethod ext(obj: pystac.asset.Asset, add_if_missing: bool = False) pystac.extensions.file.FileExtension[source]#

Extends the given STAC Object with properties from the File Info Extension.

This extension can be applied to instances of Asset.

classmethod get_schema_uri() str[source]#

Gets the schema URI associated with this extension.

property header_size: Optional[int]#

Get or sets the header size of the file, in bytes.

properties: Dict[str, Any]#

The Asset fields, including extension properties.

property size: Optional[int]#

Get or sets the size of the file, in bytes.

property values: Optional[List[pystac.extensions.file.MappingObject]]#

Get or sets the list of MappingObject instances that lists the values that are in the file and describe their meaning. See the Mapping Object docs for an example. If given, at least one array element is required.

class pystac.extensions.file.FileExtensionHooks[source]#

Bases: pystac.extensions.hooks.ExtensionHooks

migrate(obj: Dict[str, Any], version: pystac.serialization.identify.STACVersionID, info: pystac.serialization.identify.STACJSONDescription) None[source]#

Migrate a STAC Object in dict format from a previous version. The base implementation will update the stac_extensions to the latest schema ID. This method will only be called for STAC objects that have been identified as a previous version of STAC. Implementations should directly manipulate the obj dict. Remember to call super() in order to change out the old ‘stac_extension’ entry with the latest schema URI.

prev_extension_ids = {'file'}#
schema_uri: str = 'https://stac-extensions.github.io/file/v2.0.0/schema.json'#
stac_object_types = {STACObjectType.ITEM}#
class pystac.extensions.file.MappingObject(properties: Dict[str, Any])[source]#

Bases: object

Represents a value map used by assets that are used as classification layers, and give details about the values in the asset and their meanings.

apply(values: List[Any], summary: str) None[source]#

Sets the properties for this MappingObject instance.

Parameters
  • values – The value(s) in the file. At least one array element is required.

  • summary – A short description of the value(s).

classmethod create(values: List[Any], summary: str) pystac.extensions.file.MappingObject[source]#

Creates a new MappingObject instance.

Parameters
  • values – The value(s) in the file. At least one array element is required.

  • summary – A short description of the value(s).

classmethod from_dict(d: Dict[str, Any]) pystac.extensions.file.MappingObject[source]#
properties: Dict[str, Any]#
property summary: str#

Gets or sets the short description of the value(s).

to_dict() Dict[str, Any][source]#
property values: List[Any]#

Gets or sets the list of value(s) in the file. At least one array element is required.